-
If input array is sorted then - Binary search OR Two pointers / sliding window
-
If asked for all permutations/subsets then - Backtracking
-
If given a tree then - DFS - BFS
-
If given a graph then - DFS - BFS
-
If given a linked list then - Two pointers
-
If recursion is banned then - Stack
-
If must solve in-place then - Swap corresponding values - Store one or more different values in the same pointer
-
If asked for maximum/minimum subarray/subset/options then - Dynamic programming
-
If asked for top/least K items then - Heap - QuickSelect
-
If asked for common strings then - Map - Trie
-
Else - Map/Set for O(1) time & O(n) space
-
Sort input for O(nlogn) time and O(1) space
-
Notifications
You must be signed in to change notification settings - Fork 0
hassannajj/leetcode
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Leetcode Problems
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published