## Senior Software Development Engineer Interview Questions

- 0of 0 votes
producer consumer problem

- 0of 0 votes
Define a singleton class

- 0of 0 votes
Make 100 HTTP GET requests to http://en.wikipedia.org/wiki/Main_Page and print the following in Java

statistics for the response time to stdout:

• 10th, 50th, 90th, 95th, 99th Percentile

• Mean

• Standard Deviation

Your solution must be parallel. You must make at least N (say 10, but should be configurable)

requests at a time.

Explain design choices, known limitations and edge cases.

What challenges did you face? How would you improve the code if you had more time?

- 0of 0 votes
With times stored in the format "HH:MM:SS", find the number of "interesting" times that can be displayed between two given times S and T (inclusive).

An "interesting" time is one that can be displayed with at most 2 characters.

For example S "15:15:00" and T "15:15:12" would return the count of 1 as the only "interesting" time between S and T (inclusive) is "15:15:11".

Another example, S "22:22:21" and T "22:22:23" would return the count of 3 because of the following times: "22:22:21", "22:22:22", "22:22:23"

Constraints:

S <= T

00 <= HH <= 23

00 <= MM <= 59

00 <= SS <= 59

- 0of 0 votes
Given a Matrix A,

The rules for movement are as follows :

1. Can only move Right or Down from any element

2. Can only move within the row and column of element we start from intially.

3. You can only visit or cross an element if its value is lesser than the value of element you start from.

Find total number of elements one can visit, If one starts from an element A(i,j) where i-> row and j-> column.

Note : You have to print this output for each matrix element.

Input : Matrix

1 2 3

2 3 1

3 1 2

Output:

1 1 3

1 3 1

3 1 1

- 0of 0 votes
Find the label with max width of a tree.

// 0 A

// /|\

// 1 B C D

// /| | \

// 2 E F G H

Answer is 2 here.

- 0of 0 votes
You are given an array of values, (not necessary integers or positives) and a value. You have to print all the pairs whose sum is given value. Write a general method which can accept integers, float, doubles, long, or any other thing where this make sense.

- 0of 0 votes
1) write a concurrent singleton class.

2) Write a factory method class, and how it is used

3) Define a sealed class.

4) What if we want to replace sealed class with another class and use this new class where ever we have used our sealed class, how do you do that.

5) What would you look in a code review?

6) Do you know about adapters, bridges design pattern

7) Define async await method, how do we read data in task library

8) What are the other methods of making your call multi-threaded

9) Do you know Linq queries

10) How to make defer/no defer execution in Linq Queries.

11) Where do you use singleton class, give at least three examples

12) When we use singleton class and when static, both have the single instance.

- 1of 1 vote
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
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
Write a Program in Java, You have an Employee class |

class Employee{

String name;

Integer id,

Employee manager

}

Each employee has a manager and the manager of CEO is null. Find all direct and indirect reportees of a manager.

Eg. Say Employee e1 reports to CEO,

e2 and e3 reports to e1,

e4 and e5 reports to e2,

e6 reports to e3.

Then by giving e1 as input, output should be e2, e3, e4, e5 and e6.

- 0of 0 votes
/**

* A tournament tree is a binary tree

* where the parent is the minimum of the two children.

* Given a tournament tree find the second minimum value in the tree.

* A node in the tree will always have 2 or 0 children.

* Also all leaves will have distinct and unique values.

* 2

* / \

* 2 3

* / \ | \

* 4 2 5 3

*

* In this given tree the answer is 3.

*/`class Node { Integer value; Node left, right; Node(Integer value, Node left, Node right) { this.value = value; this.left = left; this.right = right; } } class Solution { /** * This should return the second minimum * int value in the given tournament tree */ public static Integer secondMin(Node root) { } }`

- 0of 0 votes
Given a number n that represents n lockers and n students. All lockers start closed. First student goes and opens all the lockers. Second goes and toggles 2nd, 4th, 6th.. lockers. Third student toggles 3rd, 6th, 9th.. lockers. Print the lockers that remain open after all students pass.

`public void lockers(int n) { // Implementation here }`

- 0of 0 votes
Given 3 sorted arrays. Find(x,y,z), (where x is from 1st array, y is from 2nd array, and z is from 3rd array), such that x<y<z.

x = element(s) from array 1

y= element(s) from array 2

z = element(s) from array 3

I can have more than 1 elements from each array. But at least 1 from each array is mandatory and elements from .`int[] arr1 = {3}; int[] arr2 = {11, 13, 16}; int[] arr3 = {45}; Correct Output : 7 (3,11,45) (3,13,45) (3,13,16,45) (3,16,45) (3,11,13,45) (3,11,16,45) (3,11,13,16,45)`

Need to find the number of such sequences.

- 1of 1 vote
You have two servers. Both of these servers have an identical file with billion characters except for one single character. These servers are connected over a very slow connection.

How do you find the different character?

My ans: split those files in to batches of characters of 10,000 (say), now calculate checksum and compare the checksums for the chunks of 10,000 character lines. So now you are just comparing 'ints' and not the files per say. (remember the connection is very slow)

His question: How do you optimize this?

- 0of 0 votes
Write a Java Program in which a class takes four integer arguments as input(a, b, c and d). Do addition of (a+b) on one thread, addition of (c+d) on another thread and multiplication of(a+b) * (c+d)) on main thread.

Like: Thread1 = (a+b)

Thread2 = (c+d)

Main Thread = (Thread1 * Thread2)

- -1of 1 vote
Given a few pairs of names in the order child, father. The input is a person name and level number. The output should be the number of children in that particular level for the person given.

Example:

Input:

[

{Ram, Syam},

{Akil, Syam},

{Nikil, Ram},

{Subhash, Ram},

{Karthik, Akil}

];

Syam 2

Output: 3 (Syam has Ram and Akil in level 1 and in level 2 he have Nikil, Subhash, Karthik. So the answer is 3).

- 0of 0 votes
Create a RESTful microservice that implements a card shuffling algorithm, as defined below. Should have evidence of test-driven development with unit tests. Use best practices of interfaces and generics for abstraction, preferably implementing a strategy pattern for deploy-time dependency injection of a shuffling algorithm.

Requirements:

· Create a microservice that stores and shuffles card decks.

· A card may be represented as a simple string such as “5-heart”, or “K-spade”.

· A deck is an ordered list of 52 standard playing cards.

· Expose a RESTful interface that allows a user to:

· PUT an idempotent request for the creation of a new named deck. New decks are created in some initial sorted order.

· POST a request to shuffle an existing named deck.

· GET a list of the current decks persisted in the service.

· GET a named deck in its current sorted/shuffled order.

· DELETE a named deck.

· Design your own data and API structure(s) for the deck.

· Persist the decks in-memory only, but stub the persistence layer such that it can be later upgraded to a durable datastore.

· Implement a simple shuffling algorithm that simply randomizes the deck in-place.

· Implement a more complex algorithm that simulates hand-shuffling, i.e. splitting the deck in half and interleaving the two halves, repeating the process multiple times.

· Allow switching the algorithms at deploy-time only via configuration.

- 0of 0 votes
public interface FirstCommonAncestor {

/**

* Given two nodes of a tree,

* method should return the deepest common ancestor of those nodes.

*

* A

* / \

* B C

* / \ \

* D E H

* / \

* G F

*

* commonAncestor(D, F) = B

* commonAncestor(C, G) = A

* commonAncestor(E, B) = B

*/

Node commonAncestor(Node one, Node two);

}`class Node { final Node parent; final Node left; final Node right; public Node(Node parent, Node left, Node right) { this.parent = parent; this.left = left; this.right = right; } boolean isRoot() { return parent == null; } }`

- 0of 0 votes
With given Binary Tree below, traverse the tree and print the tree from bottom up order

1

/ \

2 3

/\ /\

4 5 6 7

output: 4567231

Hint: the traverse is called "Level Order Tree Traversal"

I hope someone memorize this traversal and pass the exam and all these companies judging canditates with one algorithm could think they hired the best canditate.

- 1of 1 vote
determine whether a word is in a stored list;

the list doesn't fit into memory;

no disk access allowed, for lookups, memory access only;

no false positives allowed, false negatives ok

- 1of 1 vote
Design a service to generate unique 64 bit IDs

- 0of 0 votes
Write a code to convert from long type time to date using java?

Eg: 324561092314 to 02/20/2015

- 0of 0 votes
Write a code to find index of integer item in an integer array using java? Note : Complexity should be less than O(n) or with out using any for loop.

- 3of 3 votes
Given an array of 1 billion numbers with just a few 100 missing, find all the missing numbers. you have only enough memory to store only 10k elements

- 0of 0 votes
You are designing the client side of a Survey website. Provide the list of classes and methods you will use to break the problem down. Also, provide the API interaction with server.

- -1of 1 vote
You are given the arrival and departure times of airplanes at an airport for a single day. Schedules for the airplanes remain the same across all days. You are to determine the number of gates the airport should have so that no plane spends time waiting for a gate.

arr = [9:30, 11:15, 16:30]

dep = [11:45, 11:30, 16:45]

Arr array is sorted by time. And departure array is sorted by corresponding arrival times. Plane 'i' arrives at time arr[i] and departs at time dep[i]

Notes:

After some questions, it was decided that minute was the smallest unit of time we cared about. Gate was considered occupied on the arriving minute, but empty on the departing minute. And that the arrival and departure times could be represented as such as integers. e.g. Day runs from minute 0 to minute 1339 (since using a zero-based index). So our example times represented as:

arr = [570, 675, 990]

dept = [705, 690, 1005]

- 0of 0 votes
Given a list L of numbers from 0 to n, and another number k = [0-9], find how many times k appears in L. If the target number in L is more than one digit, treat each digit separately. For example, k=0 appears twice in L = [0,10].

- 1of 1 vote
Two friends Kohli and Dhoni want to test their friendship to check how compatible they are. Given a list of n movies numbered 1,2,3....n and asked both of them to rank the movies.

Design an algorithm to find compatibility difference between them.

Compatibility difference is the number of mis-matches in the relative rankings of the same movie given by them i.e. if Kohli ranks Movie 3 before Movie 2 and Dhoni ranks Movie 2 before Movie 3 then its a relative ranking mis-match Compatibility difference is the maximum number of mis-matches

Sample Input

5

31245

32415

Sample Output

2

Explanation

Movies are 1,2,3,4,5. Kohli ranks them 3,1,2,4,5, Dhoni ranks them 3,2,4,1,5. Compatibility difference is 2 because Kohli ranks movie 1 before 2,4 but Dhoni ranks it after.

- 2of 2 votes
Swap the elements in Kth position from the start and end of a link list.

ex:

input: list: 1,2,4,5,7,8 & K=2

output: 1,7,4,5,2,8