## Recent Interview Questions

- 0of 0 votes
There is a 10 lakh switches out of which any random at max 1000 switches are on and robot is pointing to any number. And its took 1 sec time to off one switch.

Suggest any algorithm in which the it took minimum time to off all the switches.

- 0of 0 votes
find consecutive integers in a list that give you the biggest sum

Like for -2 5 -1 7 -3 it would be 5 -1 7

- 1of 1 vote
Check if an integer array is arithmetic sequence.

Example: 1, 2, 3, 4, 5, 6, 7, 8 => true

1, 3, 5, 7, 9 => true

Array may not be sorted.

- 0of 0 votes
Write the function READ, which is passed two double pointers pointing to the head pointers of two linked lists.

One list will hold even integers, the other one will hold odd integers. READ reads a series of integers. It separates adds odd integers to the first list, and even ones to the second, all in sorted order.

- 0of 0 votes
An Integer array is given,

Find the combination of number in the array which satisfies the equation: a to the power b= c.

A number should not be repeated in multiple combination.

1. a and b are adjacent no. in the array.c can be any where in the array.

2.No other array or data structure can be used. However modification of current array is possible.

Define a function which will take array as input and generate a output array (a modification of input array).

Example: Input array: 1 2 3 8 5

out put: 2 3 8 0 0

- 0of 0 votes
Second Least common element from an Integer array.

Example:

[5,5,4,5,4,6,6,6,1,3,3,4,4,5,4]

Answer: 3

Reason: {1=1, 3=2, 4=5, 5=4, 6=3}

- 0of 0 votes
Write test cases for siri mobileapp?or give me test cases for siri app9mobile)

- 0of 0 votes
Design a chat application. How will u handle huge data?

- 0of 0 votes
Design an online pizza delivery system. Complete OO Design needed.

- 0of 0 votes
Find the output of the following program:

#include<stdio.h>

int main()

{

int x=10; int y;

{

y=x++;

}

printf("%d",x);

}

Answer: 11

doubt: why the answer is not 10.

- 0of 0 votes
Given a binary tree, we are supposed to find nth smallest element.

- 0of 0 votes
Give java code that takes an instance of the stable marriage problem as input and decides if there is { exactly one} stable matching for this instance (that is, the program outputs either ``unique stable matching'', or ``more than one stable matching'').

input:

3

0 1 2

1 0 2

0 1 2

1 0 2

0 1 2

0 1 2

Output:

more than one stable matching

- 1of 1 vote
Remove duplicates from string given " cutcopypaste " Return "uoyase"

- 0of 0 votes
Given a 2D array of digits, try to find the occurrence of a given 2D pattern of digits. For example, consider the following 2D matrix:

7283455864

6731158619

8988242643

3839505324

9509505813

3843845384

6473530293

7053106601

0834282956

4607924137

Assume we need to look for the following 2D pattern:

950

384

353

- 0of 0 votes
there is a file and 5 processes

how can you grant access so that

only 2 process can write to file and 1 can read file at a time

in linux

- 1of 1 vote
Given a string containing only 0 and 1's, write a function that reverses and returns the two complements of the string.

- 0of 0 votes
Hey, everyone! I'm stuck trying to add my name, character by character over a certain amount of output lines. I have to use hail stone (which I've already figured out). It needs to look like this:

Please enter a Number: 53

J 132 is an odd number, so I make 3n + 1: 160

O 234 is an even number, so I take half: 80

H 154 is an even number, so I take half: 40

N 114 is an even number, so I take half: 20

(TAB) 94 is an even number, so I take half: 10

D 84 is an even number, so I take half: 5

O 84 is an odd number, so I make 3n + 1: 16

E 90 is an even number, so I take half: 8

82 is an even number, so I take half: 4

78 is an even number, so I take half: 2

76 is an even number, so I take half: 1

The process took 11 steps to reach 1`package question3; import java.util.Scanner; public class Question3 { public static void main(String[] args) { Scanner inputScanner = new Scanner(System.in); System.out.printf("Please enter a Number: "); try { int number = inputScanner.nextInt(); int steps = 0; while (number != 1) { if (number % 2 == 0) { System.out.println(number + " is an even number, so I take half: " + number / 2); number /= 2; } else { System.out.println(number + " is an odd number, so I make 3n + 1: " + (number * 3 + 1)); number = number * 3 + 1; } steps++; } String name = "JOHN\tDOE "; System.out.print(name.charAt (0) ); System.out.println("The process took " + steps + (steps < 2 ? " step" : " steps") + " to reach 1"); } catch (Exception e) { System.out.println("The input entered is not a number. Please run again."); } }`

}

- 0of 0 votes
Without using arrays, write a Console application that reads in a list of integers, one per line, until a sentinel value of 0 (which you should be able to change easily to some other value). When the sentinel is read, your program should display the following numbers:

Smallest and largest values in the list,

Second smallest and second largest values in the list

This is what I have so far.`public static void main (String[] args) {int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; int SecondMax = Integer.MAX_VALUE; int SecondMin = Integer.MAX_VALUE; Scanner s = new Scanner(System.in); while (true) { System.out.print("Enter a Value: "); int val = s.nextInt(); if (val == 0) { break; } if (val < min) { min = val; } if (val > max) { max = val; } } System.out.println("The smallest number is: " + min); System.out.println("The largest number is: " + max); System.out.println("The second smallest number is: " + SecondMin); System.out.println("The second largest number is: " + SecondMax); }`

}}

- 0of 0 votes
How do you design a system for very large graphs(does not fit in a single machine)?

- 2of 2 votes
find the maximum depth in a binary tree.

- -1of 1 vote
given an integer array , find all combinations which sum to a given number. If a number is used once, it must not be used again.

eg if input array is 6444 and sum =10

output must be just 6 4

Give an O(n) solution

- 0of 0 votes
given a string with only paranthesis - find out if it is balanced or not

eg {}[]()

followup : scale your solution and specify the right data structure to use if you have a lot of such bracket types

- 0of 0 votes
Implement following interface so that multi-put is atomic. Expect multiple producers and consumers inserting to and extracting from this queue implementation.

/**

* threadSafe bounded blocking queue implementation. Expected to be used in a

* Producer->Consumer pattern

*/

public interface MultiPutBlockingBoundedQueue<E> {

/**

* Sets the capacity of the buffer. Can be called only once. If called more

* than once or if the passed capacity is <= 0, throw an exception.

*/

public void init(int capacity) throws Exception;

/**

* Get the next item from the queue throws Exception if not initialized

*/

public E get() throws Exception;

/**

* Put the item to the tail of the queue. throws Exception if not

* initialized

*/

public void put(E obj) throws Exception;

/**

* Put the list of items in an atomic manner. The list can be more than the

* capacity throws Exception if not initialized

*/

public void multiput(List<E> objs) throws Exception;

}

- 0of 0 votes
how can i merge 2 nodes in a graph in 1 node , need to save the in and out edges and the nodes that was merged for contribution after that

for example a graph implementation in adj list:

1->3->4->6

2->3->4->6

5->4->6

and i want to merge the nodes 3 and 4 , then new nodes should be created 7 as :

1->7->6

2->7->6

5->7->6

7->6

the node 7 also will save [include 3,4 the merged nodes]

any one can help with that please

typedef struct AdjListEntry {

int visited;

int index;

struct AdjListNode current; // node iniformation

struct AdjListEntry* next;

} AdjListEntry;

typedef struct AdjListNode {

int Uind;

char name[10];

char label[10];

adjOutEddgeLists *outEddges;

//adjInEddgeLists *inEddges;

} AdjListNode;

typedef struct adjOutEddgeLists{

AdjListNode *listNode;

adjOutEddgeLists *next;

}adjOutEddgeLists;

- 0of 0 votes
Implement a Qsort similar to the build in one in C, but use an insertion sort instead

void GoogleSort(void *ptr, int number, int SIZE, int (*functionp)(const void *, const void *)) {

}

- 0of 0 votes
If you have 1TB of unsorted long integers but 1GB of memory, devise an algorithm to efficiently sort the integers. What is the time complexity? What is the space complexity?

- 0of 0 votes
Find a 1st non-repeated char in the string for e.g. if string is "Salesforce is the best company to work for” returns 'l'

- 0of 0 votes
How to create whatapp database ?

- 0of 0 votes
Find the length of a maximum palindrome subset in an array. For example: in 1, 2, 4, 1 the maximum palindrome subset is 1, 2, 1 and the answer is 3

- 0of 0 votes
Implement a function which modifies a binary tree so that the output is the tree that is a mirror of an input tree