## Amazon Interview Questions

- 0of 0 votes
You are given with an array of 1s and 0s. And you are given with an integer m, which signifies number of flips allowed.

find the position of zeros which when flipped will produce maximum continuous series of 1s.

e.g.

input:

arr={1 1 0 1 1 0 0 1 1 1 } m=1

output={1 1 1 1 1 0 0 1 1 1} position=2

arr={1 1 0 1 1 0 0 1 1 1 } m=2

output={1 1 0 1 1 1 1 1 1 1} position=5,6

- 0of 0 votes
This test was on https://www.hackerrank.com

Input is a string of Bytes E.g.341B

Convert it to human readable form: 3 characters long (excluding decimal)

No trailing or leading zeros

E.g:

Input 341B

Output 341B

Input 12345B

Output 12.3K

Input 1234567B

Output 1.23M

Input 1000000000B

Output 1G

Do not round off

Assume input will not be more than 1G

For this problem 1000B = 1K, so on and so forth

- 0of 0 votes
Write 4 testcases for the usecase "Customer buys a book with the credit card payment option."

- 0of 0 votes
Write 4 testcases for the usecase "Customer buys a book with the credit card payment option."

- 0of 0 votes
Write 4 testcases for the usecase "Customers buy a book with the credit card payment option."

- 0of 0 votes
Write a test plan for the first time launch of a website that will sell digital books.

- -1of 1 vote
Given an array of numbers print the values in diagonal format.

Example (1) for 8 dataset

Input Array : [1, 2, 3,4,5,6,7,8]

Output

01 02 04 07

03 05 08

06

Example (2) for 45 dataset

Input Array: [1, 2, 3,4,5,6,7,8,9,10……….44, 45]

Output

01 02 04 07 11 15 19 23 27 31 35 39

03 05 08 12 16 20 24 28 32 36 40 43

06 09 13 17 21 25 29 33 37 41 44

10 14 18 22 26 30 34 38 42 45

Code in Java.

- 0of 0 votes
Replace %20 with ' '.

E.g. input: www.space%20.com

output: www.space .com

- 0of 0 votes
Suppose I am given a set of input strings input[5](five of them) and their corresponding replacement strings replace[5]. Then I am given an input text, how can I replace the strings in the text matching any of the inputs with their corresponding replacements.

Also I have to make sure that if suppose, I find a match input[0] and I replace it by replace[0], then because of that it could be possible that I have a new match for input[2] lets say because of the new characters added by replace[0]. I don't want to make replacements with replace[2].

Also I cannot use regex of java.

- 0of 0 votes
design a algo so that it receive an input

`787668 787787 787948 787980 788094 788124`

and produce the output the difference of two consecutive numbers

`119,161,32,114,30`

the input can varry to any length

- 0of 0 votes
desing a algo so that it receive an input

`787668 787787 787948 787980 788094 788124`

and produce the output the difference of two consecutive numbers

`119,161,32,114,30`

the input can varry to any length

- 1of 1 vote
`Given a String s and a hashmap containing certain decodings for all the characters of alphabet. Find all possible passwords that can be generated by replacing decodings in the string s. Note that decodings of a charachter can only be single charachters Eg: String s="abcde" decodings given a-{1,2,p,o,q} b-{2,y} c-{p} d-{4,a,m,n} e-{9,z,x} h-{1} ' ' ' x-{0} y-{4,k,l} z-{r,5} So possible set passwords will be abcde,1bcde,2bcde,pbcde,obcde,qbcde, //replace a with all possible decodings a2cde,12cde,22cde,p2cde,o2cde,q2cde,aycde,1ycde,2ycde,pycde,oycde,qycde //replace b will all possible decodings a2pde,12pde,22pde,p2pde,o2pde,q2pde,aypde,1ypde,2ypde,pypde,oypde,qypde.....//replace c will all possible decodings`

- 0of 0 votes
Implement bool isPalindrome(SingleLinkList *node) in constant Space.

Sorry for incomplete post earlier..

- 0of 0 votes
Implement bool regex() Function.

- 0of 0 votes
Implement bool isBST(Tree * root)

- 0of 0 votes
Given a file which contains large number of strings.

e.g.:my name is XYZ. My emansi XYZ i.e. it has words and reverse of words. There can be the case where no reverse word is present.He told me to print all those pair whose reverse is also present in the file.

For above example output will be:

{name,eman}, {is, si}

Constraints were Minimum space should be used and time complexity should be minimum, further he added don’t compute reverse of string at all.

- 0of 0 votes
Hi,

Anyone here who has given the Amazon work style and personality test for the SDE/SDET position? If someone could shed some light on what exactly it is?

- 0of 0 votes
Hi,

Anyone here who has given the Amazon work style and personality test for the SDE/SDET position? If someone could shed some light on what it is exactly?

- 0of 0 votes
compare the time complexity of quick ,merge and bubble sort

- 0of 0 votes
Given a sorted array, construct Balanced BST

- 0of 0 votes
Find all the Leaders in an Array.

An Array element is Leader if all the elements following that array element is lesser than or equal to it.

Ex: Arr = {13, 17, 5, 4, 6, 2}

O/p: 17, 6, 2

- 1of 1 vote
Two dices are tossed. Once die is regular and the other is biased with probabilities P(1) = P(6) = 1/6, P(2) = P(4) = 0, P(3)= P(5) = 1/3.

Determine the probabilities of obtaining the sum 4.

- 1of 1 vote
Write a function to find the nth "ugly number". ugly numbers are numbers that can only be fully divided by 1, 2, 3, 5 and itself.

- 0of 0 votes
Box stacking problem with boxes having k dimension, find max height of stack

- 0of 0 votes
Box stacking problem with variation of boxes having K DIMENSIONS , find the max height of stack of boxes

- 0of 0 votes
Find the permutation of a given string using dynamic programming . Try to do with the best possible time complexity and space complexity .

- 0of 0 votes
// You are given a rectangular grid of binary pixels that can be black or white.

// Some of the pixels may be black, but you don't initially know how many or

// where.

//

// Given a starting point (x,y), fill (i.e. make black) the region the pixel is

// in.

. . . . . . . . . . . . . . . . . . . .

. X X X . . X X X . . X X X . . X X X .

. X * X X X X . X . . X X X X X X X X .

. X . . . . . . X . -- > . X X X X X X X X .

. X . . . . . . X . . X X X X X X X X .

. X X X X X X X X . . X X X X X X X X .

. . . . . . . . . . . . . . . . . . . .

* . . . . . . . . . X X X X X X X X X X

. X X X . . X X X . X X X X X X X X X X

. X . X X X X . X . X X . X X X X . X X

. X . . . . . . X . --> X X . . . . . . X X

. X . . . . . . X . X X . . . . . . X X

. X X X X X X X X . X X X X X X X X X X

. . . . . . . . . . X X X X X X X X X X

See the correct drawing here: https://stackoverflow.com/questions/26079328/given-a-starting-point-x-y-fill-the-region-in-a-grid-the-pixel-is-located

- 1of 1 vote
n mice are playing in the desert, when one of them notices some hawks flying in the sky. It alerts the other mice who now realize that the hawks are going to attack them very soon. They are scared and want to get inside holes to ensure their safety.

Mice and holes are placed on a straight line. There are m holes on this line. Each hole can accommodate only 1 mouse. A mouse can either stay at its position, or move one step right from x to x+1, or move one step left from x to x-1. Any of these movements takes 1 minute.

Assign mice to holes so that the time required for all the mice to move inside the holes is minimized.

Input Format

The first line contains an integer T, the number of test cases. This is followed by T blocks of input:

First line contains 2 positive integers n and m separated by a single space.

Next line contains n space separated integers, denoting the positions of the mice.

Next line contains m space separated integers, denoting the positions of the holes.

Note: No two holes have the same position.

Output Format

For each testcase, print the minimum time taken by all the mice to reach inside the holes.

Constraints

1 ≤ T ≤ 17

1 ≤ n ≤ 131072

1 ≤ m ≤ 131072

n ≤ m

-108 ≤ mouse[i] ≤ 108

-108 ≤ hole[j] ≤ 108

Sample Input

1

3 4

2 0 -4

3 1 2 -1

Sample Output

3

Explanation

One possible solution is :

Assign mouse at position x=-4 to hole at position x=-1 -> 3 minutes

Assign mouse at postion x=2 to hole at position x=2 -> 0 minutes

Assign mouse at postion x=0 to hole at postion x=3 -> 3 minutes

So the answer is 3, after 3 minutes all of the mice are in the holes.

- 0of 0 votes
non recursive method to calculate height of the binary tree.

- 0of 0 votes
you have a dictionary which will return true if the word is present in it otherwise false. You have a string "ABC", check if anagram of "ABC" is present or not. the condition was not to generate the all the anagram of ABC. (Assumption: you can store the dictionary in trie or hashmap (any data structure) and no need to implement the dictionary)