## Recent Interview Questions

- 0of 0 votes
`class Log{ String fun_name; String enterOrExit;// enter or exit int time; public Log(String fun_name, String enterOrExit, int time){ this. fun_name = fun_name; this. enterOrExit = enterOrExit; this.time = time; } } public void printInclusiveAndExclusiveTime (List<Log> logs){ } Log for some functions, calculate the inclusive time and exclusive time for each function E.g Fun_name enter / exit time F1 enter 1 F2 enter 2 F2 exit 3 F1 exit 4 F1: inclusive time = 4-1 = 3, exclusive time = 3-1 = 2 F2: inclusive time = 3-2 = 1, exclusive time = 1`

- 0of 0 votes
For a given Sum and N print all the combinations

For Example Sum = 16 and N=2

Then Answer :

16,0

15,1

14,2

13,3

12,4

11,5

10,6

9,7

8,8

7,9

6,10

5,11

4,12

3,13

2,14

1,15

0,16`private void recursivePrint(int sum, int n, int data[], int len, int originalSum) { if (n == 0) { int sum1 = 0; for (int j = 0; j < len; j++) { sum1 += data[j]; } if (sum1 == originalSum) { for (int j = 0; j < len; j++) { System.out.print(data[j] + " "); } System.out.println(); } return; } for (int i = 0; i <=sum; i++) { // System.out.println(" len: "+len+" sum: "+sum+" i: " + i+" n:"+n) data[len] = i; recursivePrint(sum - i, n - 1, data, len + 1, originalSum); } } }`

Need a better solution so that we can store previous results by using hashmaps

- 0of 0 votes
Amazon SDE 2 On-site (1 of 4 Rounds)

In a file system stored a large amount of user’s browsing data, including the urls that the user visited. Design a function that outputs the longest common path of all the urls.

Having finished the code, I was asked to analyze the complexity.

- 0of 0 votes
Amazon SDE 2 On-site (4 of 4 Rounds)

Assume that there is an e-book application. For every book the sharable part of the book content cannot exceed 10% of the whole book. Design a module to decide whether the current part of content is sharable.

The description given is vague. I had to push him with questions to give the details.

At first I thought the problem was about strStr. But then the interviewer said that even if there are two paragraphs of the book content with the exact same texts, as long as they are not in the same place, they would be considered different content.

I then realized it’s a question about merging segments - have a helper to find each pair of start and end point of the input content (given multiple separated paragraphs). Then merge the intervals and see if they combined exceed 10% of the entire book.

The interviewer approved my solution and ask me to code it.

Overall I feel like that the Amazon SDE II Interview doesn’t focus on just algorithm. It’s more about problem solving in practice and then implement the only core function on whiteboard.

- 0of 0 votes
I have a series of strings sort {"A","B","C","D"....}

Sort them and display them in 4 columns.Instead of displaying horizontally they should be display vertical if the string size is greater than 4.

Important:null should be in last row alone

eg

A C D E

B

If string size is less than 4

A B C D

Also,the program should be production ready and reusable,readjust the values upon deletion.

- 0of 0 votes
You are given an array of integers and a number K. You have to find the any continue sub-array whose elements sum is K. Please note that, the array may have positive, negative, and zeros as its element.

The desired complexity is O(N).

Example:

Input: [7 0 9 -10 0 789], K = 0

Output: Array from index 1 to Index 1.

Input: [1 2 3 5 -10] K = 0

Output: Array from Index 1 to Index 4.

If K = -2, Output would have been SubArray from Index 2 to Index 4.

- 0of 0 votes
You are given a positive integer number and you have to return the greatest smaller tidy number of this input number. If the input number itself is tidy, then, it become the answer

Example

Input: 1234

output: 1234

input: 100

output: 99

input 143456

output: 139999.

PS.A tidy number is a number whose digits are in non-decreasing order.

- 0of 0 votes
You are given a positive integer number and you have to return a boolean telling whether the input number is a tidy number or not. A tidy number is a number whose digits are in non-decreasing order. For example, 1234 is a tidy number, 122334 is also a tidy number but 143567 is not a tidy number.

- 0of 0 votes
You are given an integer array. You have to return/print an array where kth element of this array is the multiplications of all the elements from 0 to k-1 and from k+1 to n-1.

Example

input: [1 2 5 6]

output: [60 30 12 10]

- 0of 0 votes
Perform an efficient DeepCopy of a linked list whose node is like below:

`public class Node { public int Value {get;set;} public Node Next{get;set;} public Node Random{get;set;} }`

The Random field points to any random node in the list.

- 0of 0 votes
Design an electronic voting system for india , design its schema , scaling its working, failure conditions & optimization

- 0of 0 votes
find the isomorphic pairs of string !!

a string is said to be isomorphic if its each alphabets can be replaced by another alphabet

for ex "abca" and "zxyz" are isomorphic but "abca" and "pqrs" is not isomorphic

conditions :

1 - A character can be replaced by itself. for ex "abcd" and "pbfg" are isomorphic .

2- No two characters can be replaced by same character . for ex "abcd" and "bbcd" are not isomorphic .

- 0of 0 votes
Find the subarray within an array (containing at least TWO number) which has the largest sum.

For example, given the array [-2,-1,-3,-4,-1],

the contiguous subarray [-2,-1] has the largest sum = -3.

try to do it in O(n) time

Followup, if input is stream, how to solve it

public int maxSubArray(int[] nums) {}

- 0of 0 votes
You are given a BST of integers and an integer K. You have to find the smallest greater integer then K in the BST.

Ex`40 --- 50 --- 80 | | | 45 20 --- 30 | | 10 K = 35 Output: 40`

- -1of 1 vote
Sorry had to remove this question

- 0of 0 votes
Given the following set of strings, write a function that stores this information.

// /Electronics/Computers/Graphics Cards

// /Electronics/Computers/Graphics Cards

// /Electronics/Computers/SSDs

// /Electronics/Computers/Graphics Cards

// /Electronics/Computers/SSDs

// /Electronics/TVs

// /Electronics/Computers/Graphics Cards

// /Electronics/TVs

// /Electronics/TVs

// /Garden

// /Automotive/Parts

Your datastructure should be able to provide information as such:

// / = 11

// /Electronics = 9

// /Electronics/Computers = 6

// /Electronics/Computers/Graphics Cards = 4

// /Electronics/TVs = 3

// etc

// ["/Electronics/Computers/Graphics Cards", "/Garden"]

- 0of 0 votes
Write code for the following: given a text file containing this information (Date the customer is logged in, tab, customer id)

04/11/2017 /t 0003

04/12/2017 /t 0003

04/13/2017 /t 0004

04/13/2017 /t 0003

How to get the list of those customers that log in on three consecutive days.

- 0of 0 votes
OOPS: How to design Amazon locker? Provide code using OOP

- 0of 0 votes
How to merge two binary trees in place? (without creating a new node)

- 0of 0 votes
13. What types of proactive selling / leads generation have you done and how do you go about preparing?

- 0of 0 votes
12. Please provide an example on how you developed a strategy for selling into the highest levels of your accounts or assigned territory?

- 0of 0 votes
10. How would you characterize how you work with your colleagues? and your manager?

11. And how you worked with other functional areas: marketing, application engineering, product development, customer support, etc.? When would you leverage those resources?

- 0of 0 votes
5. Describe your selling/ support approach to Middle East and North Africa companies?

- 0of 0 votes
1. Why does it interest you to join MathWorks?

- 0of 0 votes
Consider 10 years down the line we have a mobile device which have 10 TB hard disk.Consider the device a file of 5TB and RAM on the device is 1GB. How will you sort the file of 5TB. You can use extra space but RAM is 1GB which is used by other application on the device also.

- 0of 0 votes
We define a k-subsequence of an array as follows

1) it is a subsequence of consecutive elements in the array

2) the sum of the subsequence's elements s, is evenly devisible by k(i.e. s % k == 0)

Given an integer and input array, find out the number of k-subsequences.

Example: k=3 and array be [1 2 3 4 1]

Output: 4 ({1 2},{1,2,3},{2,3,4},{3})

- 0of 0 votes
You are given an array with duplicates. You have to sort the array with decreasing frequency of elements. If two elements have the same frequency, sort them by their actual value in increasing order.

Ex: [2 3 5 3 7 9 5 3 7]

Output: [3 3 3 5 5 7 7 2 9]

- 0of 0 votes
You are given two string (like two statements). You have to remove all the words of second string from first string and print the remaining first string. Please maintain the order of the remaining words from the first string. You will be only removing the first word, not all occurrence of a word.

Example: Str1 = "A Statement is a Statement", Str2 = "Statement a"

Output: "A is Statement"

- 0of 0 votes
You are given an integer, print its 4th least significant bit

- 0of 0 votes
A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.

For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of length 3. The number 20 has binary representation 10100 and contains one binary gap of length 1. The number 15 has binary representation 1111 and has no binary gaps.

Write a function:

int solution(int N);

that, given a positive integer N, returns the length of its longest binary gap. The function should return 0 if N doesn't contain a binary gap.

For example, given N = 1041 the function should return 5, because N has binary representation 10000010001 and so its longest binary gap is of length 5.

Assume that:

N is an integer within the range [1..2,147,483,647].

Complexity:

expected worst-case time complexity is O(log(N));

expected worst-case space complexity is O(1).