## Senior Software Development Engineer Interview Questions

- 0of 0 votes
We have a file path as like this:

wchar_t* pCompletePath = L"\\?\UNC\10.1.3.23\TOKEN$\0x464564564576\C\FileDrive\Testcase.doc";

Write a C++ function which will take input argument as above string and gives output as L”\\?\UNC\10.1.3.23\TOKEN$\C\FileDrive\Testcase.doc” (Removing one token after the TOKEN$)

Constraints: TOKEN$ will be there for all strings, so we can use that for search

- 0of 0 votes
A file is given which consists of 3 columns : date, city and temperature. For ex:

Date City Temperature

09-11-2015 Delhi 45

09-11-2015 Bangalore 24

09-11-2015 Ranchi 28

and it should support following type of queries:

1) What is the temperature of Bangalore on 9th November?

2) Give 5 hottest/coldest cities name on 9th November

You can preprocess the data and keep it in way that above query can be done in minimal time.

Which data structure will you use and how will you store the data?

- 1of 1 vote
Input argument of a method is a list of char array. The method have to print all the possible combination of input char(s)...For example if the input argument has ['A','B','C','D'] the output should be A,B,C,AB,AC,AD,BC,BD,CD,ABC,ACD,BCD,ABCD

- 2of 2 votes
Evaluate the value of an expression given in Reverse Polish notation

- 4of 4 votes
This question was asked in the Technical Design round.

How would you design a system to provide the top trending topcis in the last 5m/1hour/24hours

The most trending topic should appear first

A topic is said to be trending if it is shared the most. We are talking about a typical multi user environment (something like twitter, facebook).

- 1of 1 vote
This question was asked in the first coding round on-site.

Give two sorted lists List<Integer> a and List<Integer> b.

Find

the Union of these two lists -> the union list should also be sorted

the Intersection of these two lists -> Intersection list should also be sorted.

- 1of 1 vote
Those who've attended on-site interview with LinkedIn might know that there are 2 rounds of coding interviews. This question was asked in my 2nd round of coding interview,

Given two valid dictionary words of same length, write a function which returns the minimum number of steps to go from the first to the second word.

You can change only one character at a time. Also, the word formed at every step should be a valid dictionary word.

Eg: Provide minimum steps to go from 'cat' to 'dog'

cat -> bat -> bet -> bot -> bog -> dog

Ans: 5

- 2of 4 votes
Given two arrays were digits of one array represent a number,maxmise the number by replacing it with elements of second array.

eg:

arr={3,1,4,5,6}

rep={1,9,5,2,3}

after replacement

arr={9,5,4,5,6}

one digit of rep can be used to replace only once.

- 1of 1 vote
Model a restaurant reservation system, where staff can a reservation, pull up, cancel reservations. The reservation system is very simple local to just one terminal at the restaurant not connected to network.

- 1of 1 vote
Find an algorithm to find a word ladder between 2 words by changing just one letter at a time. All the words formed should be valid dictionary words.

Eg.

FOOL ->POOL->POLL->POLE->PALE->SALE->SAGE

COLD → CORD → CARD → WARD → WARM

- 1of 1 vote
Write a program in that determines the members and parents of nested groups without using recursion.

These are the requirements.

1. A group can have 0 or more members.

2. A group can be member of one or more groups

3. A group can be member of itself.

4. If there is a path from a group either directly or through multiple hops, then that user is considered as member of the group.

5. A group can have users or groups as members

EX: Input looks like this`var groupMembers = new Dictionary<string, HashSet<string>> { { "G4", new HashSet<string> { "U1","G1"} }, { "G1", new HashSet<string> { "G2","G3","G6"} }, { "G3", new HashSet<string> { "G3","G5"} }, { "G2", new HashSet<string> { "G4","U2"} }, { "G5", new HashSet<string> { "U2","G6"} }, { "G6", new HashSet<string> { "U3"} }, };`

Signature of function is:

`private List<MyGroup> FindMembers(Dictionary<string, HashSet<string>> groupMembers)`

You need to make sure that you take care of cycles in the graph and not go into infinite recursion.

Output should look like a list of groups where a group is as follows.`private class MyGroup { public string Identity { get; set; } public Dictionary<string, MyGroup> MemberOf { get; set; } public Dictionary<string, MyGroup> Members { get; set; } public HashSet<string> Users { get; set; } public MyGroup(string name) { this.Identity = name; this.MemberOf = new Dictionary<string, MyGroup>(); this.Members = new Dictionary<string, MyGroup>(); this.Users = new HashSet<string>(); } }`

Each group object should contain all the groups it's a memberOf (directly or indirectly), all the groups that are it's members (directly or indirectly) and all users that are it's members.

- 0of 0 votes
Given a dependency list of libraries (where an item is: library X depends on library Y) generate a list describing the order in which libraries should be loaded.

Additional request: detect circular dependencies.

- 1of 1 vote
Design the (content) search autocomplete feature on Kindle

- 0of 0 votes
A paper consists of a series of consecutive numbers from 1 up to 2^n values. For example,

For case 2^1, content of the paper is,

1 2

For case 2^2, content of the paper is,

1 2 3 4

For case 2^3, content of the paper is,

1 2 3 4 5 6 7 8

There will be n number of commands for 2^n case. Below are the commands,

L – Fold the paper from Left edge to Right edge

R – Fold the paper from Right edge to Left edge

After performing the n number of commands, there will be a single number in all layer of paper, you need to write down the numbers in all layers when you see the paper from upside of it.

Please provide an efficient algorithm.

Example:

Content of the paper (2^3):

1 2 3 4 5 6 7 8

Commands: LRL

Output:

5 4 1 8 7 2 3 6

- 0of 0 votes
Suppose you have two arrays of objects. How would you find the common elements among them? How would you optimize the solution to avoid additional space?

- 0of 0 votes
Implement Priority Queue

- 0of 0 votes
Implement Least Recently Used Cache for IPAddress lookup. Assume max cache size is 1000 but it should scale well with larger number

Key of the cache is server name and value is IPAddress.

- 1of 1 vote
Given a string left rotate it by given number of times with O(n) solution

- 1of 1 vote
Given a array where each element is maximum +-k index away from it's sorted position, find an algorithm to sort such array.

- 1of 1 vote
Implement cycle detection for a spreadsheet with the characteristics outline below. Your solution should include working data structures to represent the spreadsheet and operate on a "entire" spreadsheet to indicate which cells have circular dependencies.

Spreadsheet

The spreadsheet is a collection of cells within a 2-D space of columns and rows. Columns are defined with a letter and rows are defined by a number. You can assume an upper limit of 26 columns for simplicity.

Cell values are either a number (long or double) or an expression containing numbers, operators, and references to other cells (i.e. B2 means the second column [B] and second row [2]). You can ignore the parsing of expressions for this exercise. Instead, your solution can define the data you will work with after expressions have been parsed.

Cycles

A cycle occurs when a cell refers to itself either directly or indirectly via an expression.

- 0of 0 votes
You have a coffee shop with say, a 1000 flavors of coffee. You always face a customer query asking for a certain number of coffee flavors that are closest matches to what they are drinking. Write a function which would take a coffee flavor and find a certain

number of closest flavor matches in terms of flavor.

- 0of 0 votes
You have a requirement where a user searches for a search term, which could be say, the title of a movie

and you need to find the title and then show a description of the movie. How would you implement it. Describe the data structures used. If you were going to host this service on a single machine with 250 MB of RAM while you need to handle, say 10 GB of data, how would you do this?

- 0of 0 votes
There are N pots. Every pots has some water in it. They may be partially filled . Every pot is associated with overflow number O which tell how many minimum no. of stones required for that pot to overflow. The crow know O1 to On(overflow no. for all the pots). Crow wants some K pots to be overflow. So the task is minimum number of stones he can make K pots overflow in worst case.

Array of overflow no--. {1,...On}

Number of pots--n

No of pots to overflow-- k

Let say two pots are there with overflow no.s {5,58}, and crow has to overflow one pot(k=1). So crow will put 5 stones in pot with overflow no.(58), it will not overflow, then he will put in pot with overflow no.(5), hence the total no. of stones to make overflow one pot is=10.

What are the best algorithm to do it?

- 1of 1 vote
Implement a program to reverse the linear linked list in pairs. it should handle both even number of nodes and odd number of nodes. if odd number of nodes, the last node will be the last node after reversion.

Do not move the data in the nodes. Do manipulate node pointers/references. the nodes themselves need to be manipulated, not just the data in the nodes.

For example, if the initial linear linked is,

1->2->3->4->5

after reverse it should be,

2->1->4->3->5

- 1of 1 vote
Implement a function that checks if the given binary tree is binary search tree(BST). Use tree operations to solve this. do not try solving by pre-order traversal of the tree and then checking if the array is sorted.

instead, traverse the tree for checking if it is BST.

- 0of 2 votes
Write a function that takes two arguments one array of integers that ranges between 0 and 9 and second the target sum(again integer). It produces all permutations strings of the input digits that equals the target sum.

For example, if input is array 2, 3, 5 and target sum is 10, then the output should be:

22222 because 2+2+2+2+2 = ,10

2323 as 2+3+2+3 = 10

3232

55

2233

3322

532

235

352

etc.,

- -1of 3 votes
Write a function which returns the number of times the digit "1" appears in a number which is generated from raising 11 to the Nth power where N is passed in as an input parameter. The range of N is 0 to 1,000.

Be sure to unit test your solution.

For instance, If N is 3, the number is 1331 and the function returns 2.

If N is 5, the function returns 3.

If N is 10, the function returns 1 and so on.`public int solution(int N) { ... }`

You have 30 minutes to complete the problem.

- 0of 0 votes
I was given 90 minutes to complete this test.

I didn't understand how the sample test cases arrived at their return output. Can anyone explain?

================

Approximate Matching (Coding)

You are given 3 strings: text, pre_text and post_text. Let L be a substring of text.

For each substring L of text, we define pattern_score as follows:

* pre_text_pattern_score = highest n, such that first n characters of L are equal to the last n characters of pre_text and occur in the same exact order.

* post_text_pattern_score = highest n such that last n characters of L are equal to the first n characters of post_text and occur in the same exact order.

* pattern_score = pre_text_pattern_score + post_text_pattern_score

For example, if L = "nothing", pre_text = "bruno", and post_text = "ingenious", then

* pre_text_pattern_score of L is 2 because the substring "no" is matched, and

* post_text_pattern_score is 3 because the substring "ing" is matched.

* pattern_score is 5 = 2 + 3

Your program should find a non-empty substring of text that maximizes pattern_score.

* If there is a tie, return the substring with the maximal pre_text_pattern_score.

* If multiple answers still have a tied score, return the answer that comes first lexicographically.

Complete the definition of function string calculateScore(string text, string prefix,string suffix)

Constraints:

* text, pre_text, and post_text contain only lowercase letters ('a' - 'z')

* 1 <= |text| <= 50

* 1 <= |pre-text| <= 50

* 1 <= |post-text| <= 50

(where |S| denotes the number of characters in string S)

* It is guaranteed that an answer will always exist; i.e. there will always be a substring in text that matches either at least one character at the end of pre-text or at least one character at the beginning of post-text.

Sample case #1

text: "nothing"

prefix: "bruno"

suffix: "ingenious"

Returns: "nothing"

Sample case #2

text: "ab"

prefix: "b"

suffix: "a"

Returns: "b"

- 1of 1 vote
This is design question. Starts with small data size and then goes with bigger data size

Design an application to retrieve the value for a key as fast as possible. The data given to you doesnt change.

You are given a data file of 1GB. Its key value data with key being bytes[]. What would be your application design.

Now assume the data set is 1 TB or greater how would you change your application design.(Distributed is a possibility).

Now assume the keys are very small. What are your optimizations.

- 0of 0 votes
You are given a list of strings

/flapp/server/apache

/d/apps

/d/apps/pub

/flapp

/flocal/firms

/d/sw/java

/d/sw/orcl/jdbc

The filtered strings shoud be

/flapp

/d/apps

/d/sw/java

/d/sw/orcl/jdbc

/flocal/firms

You have to identify the problem/requirement and provide solution that can work for any input with similar pattern.