## Software Developer Interview Questions

- 0of 0 votes
Two Sum. Then follow up three sum

- 0of 0 votes
Consider a game similar to tennis. The game can be palyed by 'N' number of players. The player has to win atleast 'M' games to win a set.

Print all the possible combination of winning set for all the payers.

Where

2 <= N

1 <= M

For Example if [A, B] are the players and

if M = 2 The player has to win atleast '2' games to win a set.

The output will be

A A

A B A

B A A

B B

B A B

A B B

if M = 3 The player has to win atleast '3' games to win a set.

The output will be

A A A

A B A A

A A B A

B A A A

B B B

B A B B

B B A B

A B B B

Write an algorithm to print all the possible combination of winning set for all the payers

- 0of 0 votes
Find Duplicate number from a huge amount of data which cannot fit in the memory.

- 0of 0 votes
Find kth-largest number from a huge amount of data which cannot fit in the memory.

- 0of 0 votes
How you will design and make a website like Hackerrank? How you will measure and limit the running time and memory usage of the program.

- 0of 0 votes
Write a function that receives string with decimal number (i.e. all characters are decimal digits) and prints the sum of all possible substring-numbers, example:

sum(“123”) = 123 + 12 + 23 + 1 + 2 + 3 = 167

- 0of 0 votes
Given N number of Strings, generate all combination of these String's characters, these Strings must be N long, and must contain only one number of char from each string.

example: "abc", "def", "ghi" --> adg, adh, adi, aeg ... cfg

- 0of 0 votes
You are given the length and time of occurrence of packet and Queues which process packets. Total processing time for a packet is equal to the length of packet plus the waiting time in queue. For eg lets say we have only one queue for now, and A packet of length 5 comes at t = 1, and another packet of length 4 comes at t = 3. Total processing time for first packet is 5( no waiting time as queue is empty at t = 1) and at t = 3, 2 units of first packet is processed and 3 units remaining so, for second packet 3 units will be waiting time in queue plus 4 units for its length. Total processing time for 2nd packet is 7 units. If there are multiple queues you can add new packet in any of the other queues. Given the time and length of all incoming packets, we need to find the minimum no. of queues required such that total processing time of each packet is less than 10 units. Maximum possible no. of queues are 5. If you require more than 5 queues print -1.

Test Cases Format: First Line contains the number N, the total no. of packets and N following line contains two numbers ti, li where li is length of packet coming at time = ti units.

Test case1:

2

2 7

5 8

Test Case 2:

3

1 3

2 3

3 5

Test Case 3:

3

1 5

2 4

3 8

Output:

Case1: 2

Case2: 1

Case3: 2

Consider the following time table of incoming packets:`time packets-length 1 8 2 5 3 2 4 6`

If you put the packet in queue with minimum time then this will lead to 3 queues:

t = 1:

q1: 8

t = 2:

q1: 7

q2: 5

t = 3:

q1: 6

q2: 4, 2

t = 4:

q1: 5

q2: 3, 2

q3: 6

But its output should be 2 queues:

1) 8 in queue 1

2) 5 in queue 2

3) 2 in queue 1

4) 6 in queue 2

- 0of 0 votes
You are given an array of strings. For example, ["AB", "BC", "FOO", "ZA", "BAZ"]

- Output strings where you can get from one to the other using any ROT transformation.

ROT_1(AB) = BC

ROT_1(BC) = CD

ROT_25(AB) = ZA

AB,BC you can go from one to the other using ROT_1

Input: list of strings

Output: strings where you can get from one to the other using any ROT transformation.

Example:

Input : ["AB", "BC", "FOO", "ZA", "BAZ"]

Output: [ [ab, bc] , [ab, za] ]

AB,BC because you can go from one to the other using ROT_1

AB,ZA because you can go from one to the other using ROT_25

Do not return FOO, BAZ you can’t get from one to the other.

- 0of 0 votes
Given an array of elements print even and odd numbers out of it using 2 threads . even_thread and odd_thread.

int arr[] = {3,1 ,2, 5, 6, 7, 8, 10, 9};

- 1of 1 vote
Interleave list of lists in Java

Example:

input = [[1,2,3], [9, 0], [5], [-4,-5,-2,-3,-1]];

output = [1,9,5,-4,2,0,-5,3,-2,-3,-1]

- 0of 0 votes
given period and threshold, Assume there is a endless streaming events, each event occurs at timestamp "x". The question want you to write an API that return true if number of the events are over the threshold within the period around timestamp "x"

Ex:

period = 3, threshold =2

getEvent(10) -> false

getEvent(12) -> false

getEvent(13) -> true [10,12,13]

getEvent(20) -> false

part one: event come in order

part two: event come without order

- 0of 0 votes
Given vector<int> nums, and pair<int, int> range. Find out how many continuous subsequences within this vector sum up the number within the range.

Input: [1, 2, 3], [3,6]

Output: (4)

because [1,2,3], [1,2], [2,3], [3]

- 0of 0 votes
Each have a (x,y) coordinate.

Write an API that group three Googler together for lunch if they are close enough. Otherwise, throw them in un-schedule pool.

Distance formula = sqrt((x1-x2) ^2 + (y1-y2) ^2)

Given an int range;

Range: 2

Input | Output of API Un-schedule pool

0,0 -> [] [[0,0]]

1,0 -> [] [[0,0], [1,0]]

3,0 -> [] [[0,0], [1,0], [3,0]]

1,1-> [[0,0], [1,0], [1,1]] [[3,0]]

- 0of 0 votes
Given an vector<int> nums and an int target, you can change any element of the vector to positive or negative. How many uniquely different vector sum up to target?

Input: [1,1,1], target = 2

[-1,1,1]

[1,-1,1]

[1,1,-1]

return (3)

- 2of 2 votes
Given a string with alpha-numeric characters and parentheses, return a string with balanced parentheses by removing the fewest characters possible. You cannot add anything to the string.

- 2of 2 votes
Given a collection of two dimensional points and a number k, return the k closest points to (0,0) by Euclidean distance.

- 0of 0 votes
A group of friends are tracking the miles per gallon for each of their cars. Each time one of them fills up their gas tank, they record the following in a file:

His or her name

The type of car they drove

How many miles driven since they last filled up

How many gallons purchased at this fill up

Date of the fill

Their data is formatted as a comma separate value (csv) file with the following format for each row:(#person,carName,milesDriven,gallonsFilled,fillupDate)

Miles are recorded as floating-point numbers and gallons as integers.

Please create a program that allows members of this group to determine the miles per gallon (MPG) of each of their cars during a specific time range. Note: person may have more than one so a time range query might need to output data for one or more cars. A skeleton class will be provided; your job will be to complete the program.

The principal function for querying MPG is of the form (the exact name, data types, etc., can be learned by inspecting the "solution" class in the skeleton code):

GetRangeMPG(PersonName, StartDate, EndDate)

Returns list of objects containing (CarName, MPG)

MPG is calculated as (total miles traveled during time period)/ (total gallons filled during time period.

The dates you receive in the query should be treated inclusively.

- 0of 0 votes
Design a data structure which reads below block of text

*Status update1

**Joe is working on a bug

**Alice is on vacation

*StatusUpdate2

**Alex finished task1

and returns me an Object such that I can navigate the this nested text easily like this:

obj.children[0] - > returns "StatusUpdate"

obj.children[0].children[1] -> "Alice is on vacation"

- 0of 0 votes
Given a Tree where each node contains an attribute say color(R,G,B... etc). find subtree with maximum number of attributes.

Input:

G

/ \

B R

/ \ / \

B B R R

/ \ / \

B R R R

Output:

Input:

R

/ \

R R

\ / \

R R R

- 1of 1 vote
Partition given string in such manner that i'th substring is sum of (i-1)'th and (i-2)'nd substring. If such partition not possible then return empty arrayList.

eg.

1) given "1111223" then return ["1", "11", "12", "23"]

2) given "1111213" then return ["11", "1", "12", "13"]

3) given "11121114" then return []

- -3of 3 votes
Modify the following code:

`def GenerateGraph(data): d = {} g = Graph() for word in data: for i in range(len(word)): bucket = word[:i] + '_' + word[i+1:] if bucket in d: d[bucket].append(word) else: d[bucket] = [word] for v in d.keys(): for word1 in d[v]: for word2 in d[v]: if word1 != word2: g.addEdge(word1,word2) return g`

The objective is to find all combination of words by changing one letter at a time and adding to the graph if word exists in the dictionary.

We need to rewrite a different logic for the above code.

- -1of 1 vote
Given a list of characters, write a function to output a list of length of minimum non overlapping subsequences that can partition the input list.

For example:

Input : [a,b,c]

Output: [1,1,1]

Explanation: There are no repeated characters.

Input : [a,b,c,a]

Output: [4]

Explanation: The 'a' is repeated so one subsequence is between a to last a.

Input : [a,b,c,b,a,e,b,a,d,f,g,d,f,i,f,k,l,m,n,m,l]

Output: [8,7,6]

Explanation: max length from 1st 'a' to last 'a' is 8.

1st 'f' to last is 6 adding d to it = 7

so on

- 0of 0 votes
from robot movement tell final position of robot...

testcases:

"ULDLLUDL"

"UP 2xDOWN LEFT 4xRIGHT"

- 0of 0 votes
"Implement a job scheduler which takes in a function `f` and an integer `n`, and calls `f` after `n` milliseconds."

That's it. :)

- 0of 0 votes
Is Quicken Customer Service The Finest Customer Care?

- 0of 0 votes
Is Quicken Customer Service The Finest Customer Care?

- 1of 1 vote
The time taken by ith person to complete a task is Ki minutes.

A company wants to finish N tasks given K persons each if their given time. Find minimum time to complete N tasks using K persons. There is no waiting time between the tasks switching. Persons can start their tasks simultaneously.

For N=3 and K=2,

Input:

3 2

1

2

Output:

2

Explanation:

Person 1 will start task 1 at t=0. Person 2 will start task 2 at t=0.

At t=1, Person 1 will switch to 3rd task finishing its first task.

By the end of 2 minutes, all 3 tasks will be finished. So, minimum time taken is 3 minutes.

- 0of 0 votes
Given a string of size n consisting of 0s and/or 1s.you have to perform k queries and there are two types of queries possible.

"1"(without quotes): Print length of the longest substring with all '1'.

"2 X"(without quotes): where X is an Integer between 1 to n.In this query, you will change character at Xth position to '1' (it is possible that the character at ith position was already '1')

Input Format:

First Line of input contains n and k, where n is string length and k is the number of queries.

Next line contains a string of 0's and/or 1's of length n.

Each of next k lines contains query of any one type (i.e 1 or 2).

Output Format: For each query of type 1, print in new line the maximum size of subarray with all 1's.

Example Input:

5 7

00000

1

2 3

1

2 5

1

2 4

1

Example Output:

0

1

1

3

- 0of 0 votes
3. Complete the following function-

Node * alternateReverse( Node* head1, Node*head2){

// code goes here

}

Where ‘Node’ is the structure of a linked list node defined as:

struct Node{

int data;

struct Node *next;

};

alternateReverse() must remove the even number nodes from the linked list and append them to the end in reverse order. No extra space was allowed. It was for 5 marks.

Example:

Input-1->2->3->4->5->6

Output-1->3->5->6->4->2

Input-1->2->3->4->5->6->7->8->9

Output-1->3->5->7->9->8->6->4->2