Solutions to problems in cracking the coding interview and Leetcode problems
- Given a non-empty array of integers, every element appears twice except for one. Find that single one.
- Happy Number
- Maximum sum continous array O(n).
- Move all zero's to end of array without extra space
- Best Time to Buy and Sell Stock II (Three approaches).
- Group Anagrams
- Group Shifted Strings
- Given an integer array arr, count element x such that x + 1 is also in arr.
- Middle of the Linked List
- Backspace String Compare
- Logger Rate Limiter
- Top k most repeated elements (nlogn using Heap)
- Min stack (constant time)
- Diameter of a Binary Tree
- Largest Stone (heap log(n))
- Contigous binary array
- Perform String Shifts (o(n))
- Array Except Self
- Valid Paranthesis with * O(n)
- Number of Islands (DFS/BFS)
- Minimum Path Sum
- Search in Rotated Array (O(logn))
- Construct Binary Search Tree from Preorder Traversal
- Leftmost Column with at Least a One
- Sum of subarray with k
- Bitwise AND of all numbers using Brian Kernighan's Algorithm O(n)
- LRU Cache
- Jump Game
- Longest common subsequence
- Maximal Square
- First Unique Number
- Binary Tree Maximum Path Sum
- Root to Leaves Path in a Binary Tree
- First Bad version
- Jewels and Stone (set based solution)
- Bit Manipulation Compliment of a number
- Ransom Note (Hash solution)
- First Unique Character in a String
- Majority Element n/2
- Cousins of Binary Tree
- Check is set of line is straightline
- Valid Perfect Square using Binary Search
- Find the town judge O(n)
- Flood Fill
- Single Element Sorted Array
- Remove K digits such that number is smaller
- Trie Tree (Prefix Tree)
- Maximum sum circular sub array
- Odd-Even Linked list
- Permutation in String
- Online Stock Span
- Kth Smallest Element
- Count Square Submatrices with All Ones
- Sort Characters By Frequency
- Interval List Intersection
- Construct Binary Search Tree from Preorder Traversal
- Uncrossed Lines
- Contigous array through Hashmap
- Possible Bipartition
- Counting Bits
- Find All Anagrams in a String
- Course Schedule - Topological Sorting
- K closest point to origin
- Edit distance dynamic programming