## Software Engineer / Developer Interview Questions

- 1of 1 vote
Given an array of integers. We have to find the max element of the array, which is at multiple places in the array and return any one of the indices randomly.

- 0of 0 votes
Which is faster?

while(1) {}

or

while(2) {}

I said both have same speed as the expression inside while should finally evaluate to true or false. in this case both evaluates to true and there are no extra instructions inside the while so both have same speed of execution. Interviewer said while (1) is faster than while (2).

I do not agree . do you ?

By the way interviewer was a senior manager (i,e. does not code on day-to-day basis)

- 0of 0 votes
Come up with an algorithm for mapping the following scenario:

You have a source LED which has the following possible output combinations.

1. OFF

2. ON- Having RED SOLID color

3. ON- Having a GREEN BLINKING (one flash every second)-> This will result in LED turning OFF->ON and then OFF->ON

every one second.

When the source LED changes it's state (ON->OFF, OFF->ON, or changes COLOR ), you will get an interrupt.

As part of the interrupt handling, you will have to drive a single LED which has these possible values:

OFF-> when the source LED is OFF

RED-> when the source LED is RED SOLID

GREEN->when the source LED is green flashing.

Give the algorithm of only mapping these scenario and not the interrupt handling.

- 0of 0 votes
Implement an algorithm to print all valid (e.g., properly opened and closed) combinations of n-pairs of parentheses.

EXAMPLE:

input: 3 (e.g., 3 pairs of parentheses)

output: ()()(), ()(()), (())(), ((()))

This question is from "Cracking the coding interview" (Fourth Edition) and I think that I found mistake in the answer.

- 9of 9 votes
Output top N positive integer in string comparison order. For example, let's say N=1000, then you need to output in string comparison order as below:

1, 10, 100, 1000, 101, 102, ... 109, 11, 110, ...

- 2of 2 votes
Find the longest sequence of prefix shared by all the words in a string.

"abcdef abcdxxx abcdabcdef abcyy" => "abc"

- 3of 5 votes
Given a function

getRandomTripplet()

which returns a random triplet of letters from a string. You don't know the string using calls to this function you have to correctly guess the string. the length of the string is also given.

Lets say the string is helloworld the function getRandomTriplet will return things like

hlo

hew

wld

owo

the function maintains the relative order of the letters. so it will never return

ohl since h is before o in the string.

owe since w is after e

The string is not known you are only given length of the string.

- 0of 0 votes
Give a function

getRandomTripplet()

which returns a random triplet of letters from a string. You don't know the string using calls to this function you have to correctly guess the string. the length of the string is also given.

Lets say the string is helloworld the function getRandomTriplet will return things like

hlo

hew

wld

owo

the function maintains the relative order of the letters. so it will never return

ohl since h is before o in the string.

owe since w is after e

The string is not known you are only given length of the string.

- 0of 0 votes
given a binary tree, assign a new next pointer to each node, such that next pointer points to any node which is right side of the node(ie it may point to its sibling right node , or a left node of next subtree).

if no node on right or if the node itself if right most, the next points to null`6`

`/ \`

`7-------->2`

`/ \ / \`

`1 - ->5-->4 ->13`

- 3of 3 votes
Given a NxN matrix which contains all distinct 1 to n^2 numbers, write code to print sequence of increasing adjacent sequential numbers.

ex:

1 5 9

2 3 8

4 6 7

should print

6 7 8 9

- 0of 0 votes
Given is a matrix arr[n][n], find a submatrix sub[m][m] such summation of all the elements in submatrix is maximum.

Given condition,

1. m <= n

2. m >= 2

3. consider positive, negavive and zero integers in arr[n][n]

4. User provide n.

- 0of 0 votes
float range is only 4 byte but if apply the more than 4 byte also execute why?

- 0of 0 votes
all the problem are easy solve using printf &scanf

but my question is what is the necessity of using other input&output function

- 0of 0 votes
if apply same input for float and double .some time the vale is display &some time display not same .why this kind of output display..how to rectify the problem

- -1of 1 vote
Power set P(S) of a set S is the set of all subsets of S. For example S = {a, b, c} then P(s) = {{}, {a}, {b}, {c}, {a,b}, {a, c}, {b, c}, {a, b, c}}.

If S has n elements in it then P(s) will have 2^n elements`public List<List<int>> ComputePowerSet(int[] nums) { List<List<int>> powerSet = new List<List<int>>(); if (nums == null) return powerSet; bool[] bits = new bool[nums.Length]; bool overFlowBit = false; while (!overFlowBit) { List<int> lst = new List<int>(); for (int i = 0; i < nums.Length; i++) { if (bits[i]) lst.Add(nums[i]); } //function PlusOne returns false if the end is reached i.e. 2^n if (!PlusOne(bits)) overFlowBit = true; powerSet.Add(lst); } return powerSet; } public bool PlusOne(bool[] bits) { bool carry = true; //add i i.e. true to the bits int i = bits.Length-1; while (i >= 0 && carry) { bool b = bits[i]; bits[i] = b ^ carry; carry = b & carry; i--; } //if carry is true implies reached the end i.e. 1111 + 1 = 0000, carry = 1 return !carry; }`

- 0of 0 votes
Find the deepest node in a binary tree:

Example:

A

/ \

B C

/ \ / \

D E F G

\

H

Return Node ‘H’

- 0of 0 votes
Find the deepest node in a binary tree:

Example:

A

/ \

B C

/ \ / \

D E F G

\

H

Return Node ‘H’

- 1of 1 vote
Write a function to remove the duplicated characters from a string, and maintain the order of the characters.

ex. “abracadabra” ? “abrcd”

- 0of 0 votes
what is the difference between internal repository and internet repository?

- 0of 0 votes
what about your project performance...how can i answer this question?

- 0of 0 votes
How to convert http to https in java....can anyone knows please tell me?

- 0of 0 votes
Find the consecutive number of 1s in a unsigned integer?

eg suppose you are given 67 the binary equivalent for this is 0b1000011

so here 1 is consecutively appeared 2 time maximum

so 2 is the answer

- -1of 3 votes
Let's say you have 10,000 servers, each with a billion integers. How do you find the median ?

- 3of 3 votes
Let's say you have 10,000 servers, each with a billion integers. How do you find the median?

- 0of 0 votes
Given a string that contains exactly a single pair of parenthesis, return parenthesis and their contents, so "xyz(abc)123" yields "(abc)". etc.

Conditions:

1)No variable allowed

2)Collections not allowed

3)Regex, String.indexOf() not allowed.

- 0of 0 votes
Given a string that contains exactly a single pair of parenthesis, return parenthesis and their contents, so "xyz(abc)123" yields "(abc)". etc.

Condition: You are not allowed to use a variable anywhere, Regex is not allowed.

- 0of 0 votes
Given a string that contains exactly a single pair of parenthesis, return parenthesis and their contents, so "xyz(abc)123" yields "(abc)". etc.

Condition: You are not allowed to use a variable anywhere.

- 0of 0 votes
You have 5 data sources. There is a program which calls these data sources and returns a count value.

You need to speedup this program. How do you do that?

This is a sample code`int count = getCount(ds1); if(count < 100 ) count = count + getCount(ds2); if(count < 100) count = count + getCount(ds3); if(count < 100) count = count + getCount(ds4); if(count < 100) count = count + getCount(ds5);`

- -1of 1 vote
You have 5 data sources. There is a program which calls these data sources and returns a count value.

You need to speedup this program. How do you do that?

int count = getCount(ds1);

if(count < 100 )

count = count + getCount(ds2);

if(count < 100)

count = count + getCount(ds3);

if(count < 100)

count = count + getCount(ds4);

if(count < 100)

count = count + getCount(ds5);

- 1of 1 vote
Implement a method called printNonComments() which prints out a extract of text with comments removed.

For example, the input:

hello /* this is a

multi line comment */ all

Should produce:

hello

all

You have access to a method called getNextLine() which returns the next line in the input string.