Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Some tips to consider while problem-solving

Правка en1, от mehedi17n, 2022-08-26 22:30:20

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

Теги problem solving, analysis of problem, problem analysis, competitive topic, topicwise problems

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский mehedi17n 2022-08-26 22:30:20 779 Reference: https://github.com/seanprashad/leetcode-patterns (published)