Amazon Interview Experience (II) -Selected

  1. Online Assessment
 
1.https://algo.monster/problems/amazon_oa_find_all_combination_of_numbers_sum_to_target
2.https://leetcode.com/problems/sum-of-subarray-minimums/
Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 109 + 7.
Example 1:Input: arr = [3,1,2,4]
Output: 17
Explanation:
Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4].
Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1.
Sum is 17.
1. Tell me about a time when you couldn’t meet your deadline?2. Tell me about a time you committed a mistake?3. Have you ever failed at something? What did you learn from it?How it’s impacted your project?
1. Given the String and have to partiton the given string such that all of the ocuurence of the character in the partition should be covered.Maximize the number of partition.Input: "abccaadee"
output: 2
1 partition : "abccaa"
2 partition : "dee"
Explanation : all the occurence of character in "abccaa" is in tring itself. last occurence of 'a' is at 5th index. Same goes for every character.
Did using O(n^2) solution by maintaing the last occurence location of every character in map
PS: can be solved in O(n)
https://leetcode.com/problems/partition-labels/
2. Similar to Rotten Oranges
https://leetcode.com/problems/rotting-oranges/
should be carefull with the edges cases here( I miss one edge case)
First I started with DFS approach then move to BFS and coded
1. Street parade is going on a narrow road which is having a lane attached to it? Ferries in the parade should come out from the lane in decided order but they all entered in the lane unordered. Lane is only wide enough for single ferry so they cannot overtake and once move forward they cannot take reverse? You need to find a way to organize ferries in its order? And if they can be ordered return true else return false?Example: 5, 1, 2, 4, 3
Ouput : True
explanation : 5, 4 are not in order, pop them out and add in the list again.
Example: 4, 1, 2, 5, 3
Ouput : False
explanation : 4, 5 are not in order, pop them out and add in the list again. As in last it will not be in sequence
I told him the stack approach.I told him the stack approach.2. Print the zig-zag traversal order of binary tree?Correct Traversal: A -> B -> C -> G -> F -> E -> D
https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
I explain 2 stack approach and coded the same. He look satisfied

1. Time when you were 75% through a project and realized you had the wrong goal.
2. Time when your team members were not supporting something but you pushed and went for a more optimal solution.3.Time when you failed to meet your commitment
1. Searching in the rotated Sorted Array. Input  : arr[] = {5, 6, 7, 8, 9, 10, 1, 2, 3};
key = 3
Output : Found at index
We discuss lot of edge cases.https://www.geeksforgeeks.org/search-an-element-in-a-sorted-and-pivoted-array/

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store