Cue Direction

NoCueDirectionExplanation
1Input array is sortedBinary search, Two pointersBinary search takes advantage of the sorted nature of the array to perform efficient search operations in log(n) time. Two pointers approach can solve problems related to pairs or subsequences in the array efficiently.
2Asks for all permutations/subsetsBacktrackingBacktracking is efficient for generating all possible combinations or permutations as it tries out all possibilities by progressively building and then undoing candidates.
3Given a treeDFS, BFSDepth-First Search (DFS) and Breadth-First Search (BFS) are fundamental traversals used to visit all nodes of a tree/graph. The choice between them depends on the problem context.
4Given a graphDFS, BFSSame as for trees, DFS and BFS are used to traverse or search in graphs, the choice depends on the specifics of the problem.
5Given a linked listTwo pointersTwo pointers can be used in a linked list to solve a variety of problems including detecting cycles, finding middle node, or reverse a linked list, etc.
6Recursion is bannedStackStacks can be used to emulate the behavior of recursion (maintaining a call stack) without the need for recursive calls.
7Must solve in-placeSwap corresponding values, Store one or more different values in the same pointerSwapping values and storing different values in the same pointer can be used to modify data structures in-place without requiring extra space.
8Asks for maximum/minimum subarray/subset/optionsDynamic programmingDynamic Programming is used when a problem can be broken down into overlapping sub-problems. It is especially useful when we need to find an optimal solution, such as the maximum or minimum.
9Asks for top/least K itemsHeap, QuickSelectHeaps are efficient for maintaining a collection of highest/lowest elements (Heap). QuickSelect is a fast in-place version of the QuickSort algorithm, helpful to find the Kth smallest/largest element.
10Asks for common stringsMap, TrieMaps can be used for efficient lookup and storage of string data. Tries are efficient for problems involving prefixes and can be used to solve a variety of string-based problems.
11Comparing the size of numeric elements, with their order being relevantMonotonic stackA monotonic stack is a stack where the elements are always in sorted order.
12Dealing with arrays containing numbers in a given range and asking to find the duplicates/missing ones etcCyclic SortThe input array contains numbers in the range of 0 to n. Since all numbers are unique, place each number at its correct place, for example, placing 0 at index 0, placing 1 at index 1, and so on. Once we have every number in its correct place, we can iterate the array to find the index which does not have the correct number, and that index will be our missing number.
13Frequency / Counter / Duplicates / Common StringMapPLACE HOLDER - FILL IT LATER
14ElseMap/Set for O(1) time & O(n) space, Sort input for O(nlogn) time and O(1) spaceWhen no specific pattern is identified, a Map or Set can provide efficient operations. Sorting the input can also help in many cases, particularly for grouping and searching operations.

This table serves as a rough guide on choosing an approach to solve different types of problems in computer programming, particularly in programming interviews. The best approach might vary depending on the specifics of the problem, the input size and other constraints. Additionally, these techniques can often be combined in different ways to solve more complex problems.

Refer: Recognizing Cues in Problem Statement to Categorize Problem Classes and update this table.