-
Notifications
You must be signed in to change notification settings - Fork 19
/
🧩 Amazon_Most_Asked.txt
41 lines (31 loc) · 1.71 KB
/
🧩 Amazon_Most_Asked.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
1. Reorder Data in Log Files
- Logic is basic, question must be clear.
- understand question in scratch before starting, that's all!
2. Sum of Subarray Ranges
- Is easy, we just need to form the subarrays and calculate max and min at each step
3. 🌟 All nodes distance k in binary tree
- Question was simple if it was a graph
- Here difficlty is only that we need to traverse back as well
- Traversing back is not possible in tree! But with some extra work we can! How?
- Use map to store parent of each node! So that we can traverse back
- Also, make sure to use visited array so you don't come back from where traversing path for k
4. 🌟 Search Suggestion System (TRIE)
- Basic Trie Problem! Must be done before to do it timely :)
5. Find Triangular Sum of Array (Medium/Basic question)
- Basic array problem
6. 🌟 Flip String to Monotone increasing (1, 0's problem)
- Minor maths thinking, but need recursion before
7. kth factor of n
- Basic question, nothing complex
8. Diameter of Binary Tree
- Basic recursive solution
9. 🌟 Minimum swaps to group all 1's together (1, 0's problem)
- We need a group here, hence sliding window comes in picture
- We just need to maintain window of size = (total number of 1's) and count zeroes inside it
- Number of zeroes is the number of swaps required
10. 🌟 Design and Search design words problem (TRIE PROBLEM)
- Important to understand to limit arr as per given constraints or else Memory limit will exceed
- Important to know how to build and search trie, without that can't approach the problem
- For matching '.' we need to take a recusive approach!
11. Make Array Zero by Subtracting Equal Amount
- Logic is to note that subtracting min number from all each time is not required