## Software Engineer / Developer Interview Questions

- 0of 0 votes
A Research team want to establish a research center in a region where they found some rare-elements. They want to make it closest to all the rare-elements as close as possible so that they can reduce overall cost of research over there. It is given that all the rare-elementâ€™s location is connected by roads. It is also given that Research Center can only be build on road. Team decided to assign this task to a coder. If you feel you have that much potential..

Here is the Task :- Find the shortest of the longest distance of research center from given locations of rare-elements.

Locations are given in the matrix cell form where 1 represents roads and 0 no road..

Number of rare-element and their location was also given(number<=5)

and order of square matrix was less than equal to (20).

- 0of 0 votes
double the array element if if two element is same make first element double and second element 0 move all zero end

ex I/P; 2,2,0,4,8,0,0

O/P: 4,4,8,0,0,0,0

- 0of 0 votes
The question which has been asked is : how to share a variable across two unrelated process in Linux without using IPC.

- 0of 0 votes
The question which has been asked to me is : Print right angle triangle with stars(*) without nested loops. Implement in C programming language.

- 0of 0 votes
Design a task execution service, which accepts tasks from clients and runs them and returns result. Following is how the

Client Registration (client name, callback method)

Submit Job to service

Once executed service will return the result to client

Lets assume that 20k jobs are getting submitted per second, you need to scale it in such a way that we are able to process as much jobs per second as possible.

Further questions:

So the components are going to be a load balancer, workstations, cache, task runner and DB. How will you make sure that data is consistent among them, mimimal duplication of data and every job is ran only once.

If any machine is down, say DB, workstation etc. how that is going to be handled.

- 0of 0 votes
Given two sorted linked lists, how can you combine them into one big sorted list? Do not create additional nodes.

- 0of 0 votes
There is going to be a sale during this month. You are interested in a particular item and you found that different Vendors have different prices during different time periods. You collected the following information:

`Vendor => (start date, end date, price) both sides inclusive A => (1, 5, $20) B => (3, 6, $15) C => (2, 8, $25) D => (7, 12, $18) E => (1, 31, $22)`

As you can see, there are conflicting entries. You need to print out a non-conflicting schedule of prices, taking the best price from each period:

e.g.

(1, 2, $20), (3, 6, $15), (7, 12, $18), (13, 31, $22)

- 0of 0 votes
Given a list of currency exchange rates like this:

EUR/USD => 1.2

USD/GBP => 0.75

GBP/AUD => 1.7

AUD/JPY => 90

GBP/JPY => 150

JPY/INR => 0.6

write a method`double convert(String sourceCurrency, double amount, String destCurrency);`

For example, convert(EUR, 100, INR)

The method should minimize the number of intermediate conversions.

- 0of 0 votes
Given a grid of M*N size and robot is sitting on the top leftmost corner (0,0) and has to reach the bottom right most corner (M-1,N-1). Robot can only move up, down, left or right and cannot move diagonally. Find the shortest path on the grid.

Follow find total number of paths possible.

- 0of 0 votes
Write a function to convert a String of ip address to hex

eg: ip is 197.27.11.11 = 0xC51BBB. The conversion to hex has to be done without pre-existing library function. like String.format() etc.

- 0of 0 votes
An web service maintains logs (suppose there are multiple log files per day) of all ip address which has requested service. If there is a DOS attack on the server find all ip addresses that has sent more number of requests and block them. Can this be done without writing any function in higher programming language?

What would the function look like if written in some language like C, Java etc?

Can this be done in Time optimized and space optimized manner?

- -2of 2 votes
What is the Big O of that algorithm? What happens at runtime?

- 1of 1 vote
What's the algorithm to transform the sentence "the brown fox ran fast" in "eht nworb xof nar tsaf" (reverse any word)

- 0of 0 votes
Write a merger and separator for Linked List.

eg: 1->2->3->4->5

separator()

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

merger()

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

- 2of 2 votes
Write a Java code that take a string of parenthesis as input and return if the string is valid or not . The input will have '(' and ')' and also '*' and * serves as wild card and can be used in place of both '(' and ')' or it can be null.

For example,the String (*)(*)(** is a valid String.

Follow up: What if '[]' and '{}' are also in the string along with '()' and * can be used in place of any of them or can be considered as null?

- 0of 0 votes
You are given a tree and any of the leaf node which is given as input is set to fire. And in each unit time all the neighbouring nodes of the nodes which are already in fire also catch fire. Given a tree find the time taken for the whole tree to catch fire.

The whole catches fire meaning all nodes catches fire.

Example :

4

/ \

5 6

/ \ / \

7 8 9 10

\ \

13 11

\

12

Assume the source leaf node : 9

At 1 sec : 6 catches fire

At 2 sec : 10 and 4 catches fire

At 3 sec : 5 catches fire

At 4 sec : 7 and 8 catches fire

At 5 sec : 13 and 11 catches fire

At 6 sec : 12 catches fire

If we have access to parent pointers its easy just BFS and keeping track of visited we get the answer.

How to go about the problem if we do not have access to parent pointers ??

- 1of 1 vote
All jumbled numbers of n digits in max (worst case) O(n) and min (avg case) O(log n) time.

A number is a jumbled number if the _absolute_ difference between adjacent digits is <=1.

For an input n=3

output should be

100

101

110

111

121

122

...

and so on.

The problem is similar to the one listed here https://www.careercup.com/question?id=5729332770111488

But this problem also has a O(n or log n) limitation and the solutions listed in the above mentioned problem at the time of posting this question, do not satisfy the criteria

PS: 001 is not a 3 digit number.

210 is absolutely fine as the absolute difference between adjacent digits is <=1.

- 0of 0 votes
Design a data structure that supports 3 below operations

1. GetNextId() : It returns the auto incremental next id. i.e 1 then 2 then 3 then 4

2. Acknolwdge(int i) : receives the acknowledgement of the id that was sent by GetNextId

3. GetIdLevel() : It returns the minimum id that has not been acknowledged

- 0of 0 votes
There is a primary machine and a secondary(backup machine). Write a program to sync files from primary to backup machine

- 0of 0 votes
Design an efficient hash function to perform 2D hashing.

Your function should be O(1) time and should minimize the probability of hash collisions as far as possible.

Basically, complete the following Java code ...`class TwoDData { private int x, y; public TwoDData(int x, int y) { this.x = x; this.y = y; } public int getX() { return this.x; } public int getY() { return this.y; } @Override public int hashCode() { // COMPLETE THIS METHOD } }`

- -1of 3 votes
Using GIT, how would you checkout a file, make changes and then commit the changes.

- 0of 2 votes
Given an array A of integers, having N elements.

It is desired to compute the sum of elements from index i to index j. This query is to be executed millions of times for any i, j values.

Give an O(1) implementation of this query.

You are allowed to do only one-time O(N) pre-processing.

- 0of 2 votes
Complete the following Java function

`boolean isValidIPv4Address(String input) { // true if "input" is a valid IPv4 address // false if not // Free to use any methods from these classes String/StringBuffer/StringBuilder only // Not allowed to use anything from java.net.* }`

- 0of 0 votes
The candidate had listed Chess as his hobby, and was asked the following question.

Design a data structure to represent the game of Chess.

Follow up : Write a function which returns true if enemy king is currently under Check, else returns false.

- 0of 2 votes
Give all testcases for the following function

`int binarySearch(int A[], int N, int dataToSearch) { // this function will return the index of "dataToSearch" if found, else -1 if not found. }`

- 0of 2 votes
Design a specialized stack which supports ALL of these operations in exactly O(1) time.

`class SpecializedStack { void push(int x) { // Adds an element to this stack in O(1) time } int pop() { // removes the topmost element in O(1) time } int getMax() { // gets the largest element of this stack in O(1) time } }`

- 0of 2 votes
Two words are called anagrams if one word can be formed by shuffling the letters of another word.

e.g. "hello" and "ollhe" are anagrams.

"listen" and "silent" are anagrams.

But, "cab" and "bag" are NOT anagrams.

Problem : Given a list of English words (all lowercase), write a function to "group" the anagrams together.

e.g. Input = {"abc", "def", "cab", "money", "bca", "yomen"}

Output =

{"abc", "cab", "bca"}

{"def"}

{"money", "yomen"}

Within each "group", the anagrams can occur in any sequence.

Also, sequence of groups is irrelevant.

Expected time complexity = O(NK^2), for N words with longest word length = K.

- 0of 0 votes
Detect if a given 2D matrix is a valid solution to a valid Sudoku puzzle or not.

Basically, you are given a (N^2) x (N^2) matrix where every cell has an integer value. Check if it is a valid Sudoku or not.

- 0of 0 votes
There are N number of houses in a straight line. House at index i has valuables worth V[i].

A thief is planning to rob as many houses as possible on this straight line.

Constraint : If he robs house at index i, then he cannot rob houses at indices (i - 1) and (i + 1).

Maximize the total value of valuables which he can rob.

- 0of 0 votes
What are two possible ways of passing by reference in C# language ?

Follow up : (Answer to above is "ref" and "out").

Which one would you use and why ?