Amazon Interview Experience -Offcampus 2021

  1. Online Assessment
1. You have some number of sticks with positive integer lengths. These lengths are given as an array sticks, where sticks[i] is the length of the ith stick.You can connect any two sticks of lengths x and y into one stick by paying a cost of x + y. You must connect all the sticks until there is only one stick remaining.Return the minimum cost of connecting all the given sticks into one stick in this way.Input: sticks = [2,4,3]
Output: 14
Explanation: You start with sticks = [2,4,3].
1. Combine sticks 2 and 3 for a cost of 2 + 3 = 5. Now you have sticks = [5,4].
2. Combine sticks 5 and 4 for a cost of 5 + 4 = 9. Now you have sticks = [9].
There is only one stick left, so you are done. The total cost is 5 + 9 = 14.
2. Given the cost matrix and the initial position of the robot in matrix. Calculate the minimum cost to reach the given destination position.
Input:
{ { 1, 2, 3 },
{ 4, 8, 2 },{ 1, 5, 3 } };
output: 8
1. Given an m x n board of characters and a list of strings words, return all words on the board.Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.Input: board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]], words = ["oath","pea","eat","rain"]
Output: ["eat","oath"]
2. In the stream of data where timestamp is mentioned and we have sort it according to start and end time.
1. DP Question: Given an array of positive integers, replace each element in the array such that the difference between adjacent elements in the array is less than or equal to a given target. We need to minimize the adjustment cost, that is the sum of differences between new and old values. We basically need to minimize ∑|A[i] – Anew[i]| where 0 ≤ i ≤ n-1, n is size of A[] and Anew[] is the array with adjacent difference less that or equal to target.
Assume all elements of the array is less than constant M = 100.
Examples:Input: arr = [1, 3, 0, 3], target = 1
Output: Minimum adjustment cost is 3
Explanation: One of the possible solutions
is [2, 3, 2, 3]
https://www.geeksforgeeks.org/find-minimum-adjustment-cost-of-an-array/2. Find LCA of 2 given Node: https://www.geeksforgeeks.org/lowest-common-ancestor-in-a-binary-search-tree/3. Each element in the array represents your maximum jump length at that position.Your goal is to reach the last index in the minimum number of jumps.You can assume that you can always reach the last index.Example:Input: nums = [2,3,1,1,4]
Output: 2
https://leetcode.com/problems/jump-game-ii/
  1. What are SDLC and its type?
  2. Difference between Thread and Process?
Question : Given a file which consist of data in row and columns and we have to print of every row and column sum.
  1. Don’t ignore the edge cases and discuss them properly.
  2. Give proper LP answers ( In the STAR method ) as amazon really gives weightage to it.
  3. Don’t jump to coding directly.

--

--

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