Please read the new rule regarding the restriction on the use of AI tools. ×

mehedi17n's blog

By mehedi17n, history, 2 years ago, In English

Some tips to consider while problem-solving:

If an input array is sorted then Binary search Two pointers

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

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

  • Vote: I like it
  • -34
  • Vote: I do not like it

»
2 years ago, # |
  Vote: I like it +22 Vote: I do not like it

If the problem is hard, it doesn't work.

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

me on my way to set a contest such that all the tips above fail