## Recent Interview Questions

- 0of 0 votes
XXXX.XXXXX.626XXX.12342

Find first occurance of numberic digits, i.e 12342

- 0of 0 votes
How DataBase replication Happens in MySql Server.

how to create a slave DB from an already running master Server.

- 0of 0 votes
Design for a call center Data.

Example: A call center has Huge number of unique callers, calling anytime in a day and talking for various amount of duration.

1. Data base design.

2. Utility code to query Unique users history for a given year.

3. Draw a time series graph for the unique users 1 years behavior.

- 0of 0 votes
How to Design an Meeting scheduler

- 0of 0 votes
Implement a Message Broker, with Publisher and Subscriber. There can be multiple Topic or Subject in Message Broker.

- 0of 0 votes
Give a Runable interface, and then give a scheduler post method. This post is parallel, for example:

Method header:

public void post (Runable r) {};

Call 5 times:

Scheduler.post (r1);

Scheduler.post (r2);

Scheduler.post (r3);

Scheduler.post (r4);

Scheduler.post (r5);

The five runables are allocated to five threads and run at the same time. And then asked: how to achieve these five tasks one by one run,

- 0of 0 votes
Implement Thread safe timer with start, stop and reset functionality.

- 0of 0 votes
How to randomly select a number in an array?

array: [15, 2, 4, 5, 1, -2, 0]

Follow-up:

Given a second array freq where freq[i] represents the occurrence of the ith number in array, how to randomly select a number in array based on the frequency.

Extra requirement:

Could you complete the selection in a single-pass(go through each array only once)?

- -2of 2 votes
In school a student gets rewarded if he has an attendance record without being absent for more than once or being late for 3 times continuously.

Given a student's attendance record represented by a string with 3 possible characters 'L'(Late), 'A'(Absent), 'O' (On time),

check whether the student qualifies for the reward.

e.g.

@INPUT (String) "OLLAOOOLLO"

@RETURN (Boolean) False

The student does not qualify for reward because "LLA" means he was late for 3 times in a row.

@INPUT (String) "OLLOAOLLO"

@RETURN (Boolean) True

Follow-up:

If known the length of the attendance string is n, how many possible ways there is to attend school and make sure you get the reward.

- 0of 0 votes
In school a student gets rewarded if he has an attendance record without being absent for more than once or being late for 3 times continuously.

Given a student's attendance record represented by a string with 3 possible characters 'L'(Late), 'A'(Absent), 'O' (On time), check whether the student qualifies for the reward.

e.g.

@INPUT (String) "OLLAOOOLLO"

@RETURN (Boolean) False

The student does not qualify for reward because "LLA" means he was late for 3 times in a row.

@INPUT (String) "OLLOAOLLO"

@RETURN (Boolean) True

Follow-up:

If known the length of the attendance string is n, how many possible ways there is to attend school and make sure the student gets the reward.

- 0of 0 votes
Given an array of integers greater than zero, find if it is possible to split it in two (without reordering the elements), such that the sum of the two resulting arrays is the same. Print the resulting arrays.

- 0of 0 votes
Find K which decides the number of open brackets are equal to the number of closed brackets.

input : (())

output : 2

Reason : if we divide the string at 2nd position, we get two open brackets and two closing brackets, and they are same .

input : (())))(

output : 4

Reason : if we divide the string(not necessarily equally) at 4rth position, we have (()) on the left side and on the right side we have ))( , as you can see, on the left half, we have two opening brackets and on the right half we have two closing brackets and they are equal .

input : ))

output : 2

Reason : there is no open brackets , so if we divide taking the whole string's length, we have )) on the left half and nothing on the right half. Now you can see that on the left half there is no open brackets and on the right half there is no closed brackets.

This question should be clear by now and remember you have to find out that K .

- -2of 2 votes
Fill the arrray with elements from 0 to 9.

based on thier frequency.

a[1]=3 means, 1 is repeated for 3 times(1 must present 3 times in that array)

a[2]=4 means 2 is repeated for 4 times.(2 must present twice in that array)

- 0of 0 votes
what is the best way to pass multi dimensional arrays to a function in c/c++.(dont say pointers is best, write the best syntax)

How will you read and write a matrix, with row and column number using STL.

- 0of 0 votes
Amezon_interview_3rd round:

Fill the arrray with elements from 0 to 9.

based on thier frequency.

a[1]=3 means, 1 is repeated for 3 times(1 must present 3 times in that array)

a[2]=4 means 2 is repeated for 4 times.(2 must present twice in that array)

- 0of 0 votes
There are two integer array arrayA and arrayB in the same size and two integer countA and countB. If arrayA[i] > arrayB[i], then we increase countA by 1, if arrayB[i]>arrayA[i], then we increase countB by 1. We will do nothing otherwise. Now you are given arrayA and arrayB, write a function to shuffle arrayA and so you can get countA > countB. Assume the input array are always valid, not empty and the input is guaranteed to have answer.

For example:

arrayA = [12, 24, 8, 32]

arrayB = [13, 25, 32, 11]

After shuffle:

arrayA = [24, 32, 8, 12]

arrayB = [13, 25, 32, 11]

- 0of 0 votes
Find the Maximum number of distinct nodes in a binary tree path

- 3of 3 votes
there is a bunch of tasks, each have different time to complete, task is independent, and then there are some workers,

How to allocate tasks to these workers to minimize the total time to complete all the task. The tasks can be randomly picked from the task list.

Example

Task: 2,2,3,7, 1

Worker: 2.

Return 8, because the first worker can work on the first three tasks : 2 + 2 + 3 = 7, and the second worker can work on the last two tasks : 7 + 1 = 8, so the total time to finish all the task is 8.

public int getMini(int[] tasks, int k)

- 0of 0 votes
You are given a string S consisting of N brackets, opening "("

and/or closing ")". The goal is to split S into two parts (left and

right), such that the number of opening brackets in the left part is

equal to the number of closing brackets in the right part.

For example, given S = "(())", the function should return 2,

because:

the first two characters of S, "((", contain two

opening brackets, and

the remaining two characters of S, "))", contain

two closing brackets.

In other example, given S = "(())))(", the function should return

4, because:

the first four characters of S, "(())", contain two

opening brackets, and

the remaining three characters of S, "))(", contain

two closing brackets.

In other example, given S = "))", the function should return 2,

because:

the first two characters of S, "))", contain zero

opening brackets, and

there are no remaining characters, so they contain

also zero closing brackets.

- 3of 3 votes
Given an non-negative int array and target number, check if the target can be equal to the sum of non-negative multiples of the numbers in the array.

For example, I have three numbers 6,9,20. Ex: n = 47 then it can be determined that 47 = 9*3 + 20

n=23 then there are no combinations.

public boolean combinationSum(int[] nums, int target) {

}

- 0of 0 votes
arista-networks-interview-questions

0

of 0 votes

0

Answers

Write findMin, findNext of BST tree node has parent and write PrintBST using above two

arista-networks-interview-questions

0

of 0 votes

0

Answers

Write findMin, findNext of BST tree node has parent pointer also.

void printBST(TreeNodep root) {

TreeNodep temp , next;

temp = findMin(root);

while (1) {

printf("%d",temp->value);

next = findNext(temp);

if (!next)

return;

printf("%d",next->value);

temp = next;

}

}

- 0of 0 votes
Write findMin, findNext of BST tree node has parent pointer also. http://www.geeksforgeeks.org/find-the-minimum-element-in-a-binary-search-tree/

http://www.geeksforgeeks.org/inorder-successor-in-binary-search-tree/

- 0of 0 votes
Check if two given binary trees(expression trees with two characters 'a' and 'b' and obviously operators like +,-,*) are mathematically equivalent?

- 0of 0 votes
We have a List of FlightRoute

`public static class FlightRoute { String from; String to; int time; .... }`

and write a function to find Shortest Path: findShorestPath(String start, String end, List<FlightRoute>routes)

- 0of 0 votes
Iterate over a singly linked list backwards. Call print on each node.

Example: The list A->B->C should print as

"C B A"`class Node { public Node next; public String value; }`

There are 4 solutions

1) recursive

2) iterative with O(n) memory

3) iterative with O(1) memory and O(n²) runtime

4) iterative with O(1) memory and O(n) runtime (for this solution the initial list may be modified)

Explain all 4 solutions and write the code for solutions 3 and 4

- 0of 0 votes
You are given an array of integers.

Write an algorithm that brings all nonzero elements to the left of the array, and returns the number of nonzero elements.

The algorithm should operate in place, i.e. shouldn't create a new array.

The order of the nonzero elements does not matter. The numbers that remain in the right portion of the array can be anything.

Example:

given the array [ 1, 0, 2, 0, 0, 3, 4 ],

a possible answer is [ 4, 1, 3, 2, ?, ?, ? ], 4 non-zero elements, where "?" can be any number.

Code should have good complexity and minimize the number of writes to the array.

- 0of 0 votes
Given two strings representing very large integer numbers, find the Product. Do not use BigInt.

`using System; public class Program { public static void Main() { Console.WriteLine( GetProduct("18888888888888888888888888","19999999999999999999999999999999999999999999999999999999999")); } public static string GetProduct(string s1,string s2) { int digit1=0; int digit2=0; char[] str1=s1.ToCharArray(); char[] str2=s2.ToCharArray(); int carry; string[] result=new string[str1.Length]; string finalproduct=string.Empty; int padding=0; for(int i=str1.Length-1;i>=0;i--) { digit1=str1[i]-'0'; string resval=string.Empty; carry=0; int j; for(j=str2.Length-1;j>=0;j--) { digit2=str2[j]-'0'; int product=digit1*digit2+carry; carry=product/10; resval=resval+(product%10); } if(carry>0) { resval=resval+carry; } for(int k=0;k<padding;k++) { resval="0"+resval; } result[i]=resval; padding++; } int max=findMax(result); int count=0; int car=0; while(count<max) { int sum=0; for(int x=0;x<result.Length;x++) { if(count<result[x].Length) { sum+=result[x][count]-'0'; } } sum+=car; car=sum/10; int p=sum%10; finalproduct=p+finalproduct; count++; } finalproduct=car+finalproduct; return finalproduct.TrimStart('0'); } public static int findMax(string[] s) { int max=0; for(int i=0;i<s.Length;i++) { int len=s[i].Length; max=Math.Max(max,len); } return max; }`

}

- 2of 2 votes
Find three non-overlap windows of size k in an int array, that together has a maximum sum

of the 3k entries.

example

int[] nums = [1,2,1,2,6,7,5,1]

k = 2

output

[1,2],[2,6],[7,5]

- 0of 0 votes
How can I delete all 1,000 Gmails on my phone?

- 0of 0 votes
How can I quickly share specific emails in Gmail?