All Posts

Leetcode 130: Surrounded Regions

You are given an m x n matrix board containing letters ‘X’ and ‘O’. Capture all regions that are surrounded by ‘X’. A region is captured if it is surrounded by ‘X’ cells and cannot reach the edges of the board.

Leetcode 131: Palindrome Partitioning

You are given a string s. Partition the string into all possible substrings such that each substring is a palindrome.

Leetcode 133: Clone Graph

You are given a reference to a node in a connected, undirected graph. Each node in the graph contains a value (integer) and a list of its neighbors. Your task is to return a deep copy of the entire graph starting from the given node.

Leetcode 134: Gas Station

You are given ’n’ gas stations along a circular route, where each station has a certain amount of gas and a cost associated with traveling to the next station. The goal is to find the starting station from where you can complete a full circle. If no such starting station exists, return -1.

Leetcode 137: Single Number II

You are given an integer array where every element appears exactly three times, except for one element which appears only once. Find the element that appears only once and return it. The solution must run in linear time complexity and use constant extra space.

Leetcode 138: Copy List with Random Pointer

Given a linked list where each node contains a value, a next pointer, and a random pointer (which can point to any node in the list or be null), create a deep copy of the list. The deep copy should consist of exactly n new nodes where each node has its value set to the value of its corresponding original node, and the next and random pointers of the new nodes should represent the same list state as the original. None of the pointers in the new list should point to nodes in the original list.