## Developer Program Engineer Interview Questions

- 0of 0 votes
Write a class that represents a minimal heap. The heap class should at a minimum support the following methods:

- AllocTinyHeap() which should initialize the heap with a given amount of bytes

- DeleteTinyHeap() which frees all memory associated with the heap

- TinyAlloc() which allocates a given number of bytes on the heap if there is room

- TinyFree() which frees a specific location on the heap

You may define whatever parameters are necessary for the above methods as well as write any additional methods. Overall consideration will be given to correctness, design, code readability as well as any unit testing done. As part of a final solution please submit test cases you used to verify correctness in addition to any unit tests done.

- 0of 0 votes
I was asked to design a trading system, where there will be no of buyers and sellers will transact. The system need to have low latency, the buyers will quote no of shares, company name, price they want to buy, the sellers will quote the price they want to sell for given company, and no of shares. The system has to match the buyers and sellers and transact. This is more of design question.

I was thinking in terms of a hashmap kind a structure where the key will hash to the given company, and then there will be buckets for no of shares for buyers, with different buckets for prices, the idea is to look up in memory sellers, if a match is found then make the transaction. If the in memory data exceeds a limit implement a caching, and push the older data to the persistent store. The guy was'nt convinced this was a good design. Can someone suggest how is real time trading systems implemented, do they go for low latency queues.

- 7of 7 votes
Given a string (for example: "a?bc?def?g"), write a program to generate all the possible strings by replacing ? with 0 and 1.

Example:

Input : a?b?c?

Output: a0b0c0, a0b0c1, a0b1c0, a0b1c1, a1b0c0, a1b0c1, a1b1c0, a1b1c1.

- -2of 2 votes
Table 1: Parents -> (int id, int age)

Table 2: Children -> (int id, int age, int parent_id)

Get the parent id, his/her oldest and youngest children ids.

- -1of 3 votes
Table 1: Parents -> (int id, int age, int Child_id)

Table 2: Children -> (int id, int age, int parent_id)

Get the parent id, his/her oldest and youngest children ids.

- 0of 0 votes
Write a java program to find out 5000th number in the fibonacci series.?

For example:

5th number is 5.

6th number is 8.

10th number is 55.

5000th number is ????.

- 0of 0 votes
I was asked this during a recent interview.

Lucky number – a number is a lucky number if it comprises of combination of 4′s and 7′s.

For example , if 32 is the input number, the next nearest lucky number would be 44.

Similarly ,

43 -> 44

45 -> 47

1004 -> 4444

Input number can be of any digits.

Design an algorithm that will take any random number and return its next lucky number

- 0of 0 votes
In Byteland they have a very strange monetary system. Each Bytelandian gold coin has an integer number written on it. A coin n can be exchanged in a bank into three coins: n/2, n/3 and n/4. But these numbers are all rounded down (the banks have to make a profit).

You can also sell Bytelandian coins for American dollars. The exchange rate is 1:1. But you can not buy Bytelandian coins. You have one gold coin. What is the maximum amount of American dollars you can get for it?

Input The input will contain several test cases (not more than 10). Each testcase is a single line with a number n, 0 <= n <= 1 000 000 000. It is the number written on your coin.

Output For each test case output a single line, containing the maximum amount of American dollars you can make.

Explanation You can change 12 into 6, 4 and 3, and then change these into $6+$4+$3 = $13. If you try changing the coin 2 into 3 smaller coins, you will get 1, 0 and 0, and later you can get no more than $1 out of them. It is better just to change the 2 coin directly into $2. Pls suggest a better approach.

Here's My code:`import java.util.*; class Bytelandain { Vector v= null; Scanner sc = null; public Bytelandain() { v = new Vector(); sc = new Scanner(System.in); int i=1; String s =null; while (i<=10 ) { s = sc.nextLine(); if( s.equals("") ) break; int temp = Integer.parseInt(s); v.add(temp); i++; } for(i=0;i<v.size();i++) { showProfit((Integer)v.get(i)); } } public static void main(String args[]) { Bytelandain by = new Bytelandain(); } public void showProfit(int num) { System.out.println(computeValue(num)); } public int computeValue(int num) { int value = 0; if(num<=2) { return num; } value = getProfit(num,value); if(num >= value) { return num; } return value; } public int getProfit(int num,int value) { int sum; sum = value; sum = sum+ computeValue(num/2)+computeValue(num/3)+computeValue(num/4); return sum; } }`

- 0of 0 votes
Given a tree T of nodes such that each node contains a number. A set of nodes is a Largest independent set of T (i.e. there can be no common edge between the elements). Use dynamic programming to solve this.

No recursion only loops and table must be used, you can recurse through the tree to fill some initial values in the table

- 0of 0 votes
There is a party going on. A favorite group has to be found out. Suppose there are five people A, B, C, D and E.

A, B and C knows each other. D and E knows A, B and C. So ABC is the favorite group as all of them know each othe and

evry other in the party knows them. Question was How to find this group and which datastructure/algo will be suitable?

- 1of 1 vote
Given a string, find the largest repetitive sequence. Algo + Code

Ex: abcdefbcd – bcd, banana – ana

- 0of 0 votes
Given a paragraph of text, write a program to find the first shortest sub-segment that contains each of the given k words at least once. A segment is said to be shorter than other if it contains less number of words

- 1of 1 vote
divide a given array into two subarray (not necessary to be continuous) such that difference between sum of both array is minimum. Required was recursive code for this. tried solving using idea from min coin change problem was couldn't.

- -1of 3 votes
IF we remove next line character then program runs fine else it gives a seg fault

`#include <stdio.h> void main() { char *a[10] = {"hi", "hello", "how"}; int i = 0, j = 0; a[0] = "hey"; for (i = 0;i < 10; i++) printf("%s\n", a[i]); }`

- 1of 3 votes
Imagine x is an operand and * is a binary operator. We say a string of x and * follows Reverse Polish notation if it is a postfix notation.

For example strings xx*, x, and xx*xx** follow Reverse Polish notation.

Given a string of x and *, how many insert, delete, and replace operations are needed to make the string follow the RPN.

For example, xx* need 0 operation to follow RPN since it already follows RPN.

x*x needs two operations to become xx* which follows RPN.

*xx* needs one operation to become xx* which follows RPN.

Your algorithm should work for a string of size up to 100.

- -1of 1 vote
If the stored Proc suddenly start running slow ,what will you do??

- 1of 1 vote
1>Draw structure of cluster and non cluster index.

2>Fregrementation ,types,how to unfregement

3>When will you go for rebuild and reorginise index.

4>coloumn in (1,2,3,'null',null) what will be the result.

- 0of 0 votes
Given N numbers , [N<=10^5] we need to count the total pairs of numbers that have a difference of K. [K>0 and K<1e9]

Input Format:

1st line contains N & K (integers).

2nd line contains N numbers of the set. All the N numbers are assured to be distinct.

Output Format:

One integer saying the no of pairs of numbers that have a diff K.

Sample Input #00:

5 2

1 5 3 4 2

Sample Output #00:

3

Sample Input #01:

10 1

363374326 364147530 61825163 1073065718 1281246024 1399469912 428047635 491595254 879792181 1069262793

Sample Output #01:

0

Note: Java/C# code should be in a class named "Solution"

Read input from STDIN and write output to STDOUT.

- 0of 0 votes
Given a string, print the character which appears the maximum number of times in the string.

The string will contain only ascii characters. If there is a tie in the maximum number

of times a character appears in the string, print the character which appears first in the string.

Notes:

1. The length of the string will be between 1 and 10000, inclusive.

2. Make sure you don't print anything other than a single character in the function. Otherwise, your solution will be marked wrong.

3. You only need to complete the function printMaximumOccurringCharacter.

Sample Input #00

helloworld

Sample Output #00

l

Sample Input #01

aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz

Sample Output #01

a

Sample Input #02

abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz

Sample Output #02

a

4.

- 0of 0 votes
.There is an infinite integer grid at which N people have their houses on. They decide to unite at

a common meeting place, which is someone's house.

From any given cell, all 8 adjacent cells are reachable in 1 unit of time.

eg: (x,y) can be reached from (x-1,y+1) in a single unit of time.

Find a common meeting place which minimises the sum of the travel times of all the persons.

Input Format:

N

The following N lines will contain two integers saying the x & y coordinate of the i-th person.

Output Format:

M M = min sum of all travel times;

Constraints:

N <= 10^5

The absolute value of each co-ordinate in the input will be atmost 109

HINT: Please use long long 64-bit integers;

Input #00:

4

0 1

2 5

3 1

4 0

Output #00:

8

Explanation: Sums of travel times of the houses are 11, 13, 8 and 10. 8 is the minimum.

Input #01:

6

12 -14

-3 3

-14 7

-14 -3

2 -12

-1 -6

Output #01:

- 0of 0 votes
Consider an array which may contains the alphabets from A to Z.

suppose consider the below examples

A[9] = {A,C,D,G,D,E,A,C,A}; then the output should be in the format of A=3;C=2;D=2;E=1;G=1

A[9] = {A,B,D,C,D,B,A,B,A}; then the output should be in the format of A=3;B=3;C=1;D=2

write the logic in C. the values in array may vary. the output should count the alphabets in the array

- 1of 1 vote
Given a list/array of names(String) sort them such that each name is followed by a name which starts with the last character of the previous name.

# input

[

Luis

Hector

Selena

Emmanuel

Amish

]

# output:

[

Emmanuel

Luis

Selena

Amish

Hector

]

- 0of 0 votes
Suppose an array contains below values

A = {A,B,C,B,A,C,A,B,C,A} then the output should display in the below format

A=4;B=3;C=3

Could you please send the logic for the above question in C ?

- -1of 3 votes
Problem Statement: A child is arranging rocks in layers. He can arrange the rocks, in such way that, any layer has lesser rocks than its base layer. Given n rocks, In how many ways can the child arrange the rocks.

- 3of 3 votes
Given two unsorted integer arrays A & B of unequal length.

Find an element from A(say 'X') and another element from B(say 'Y') such that |X-Y| is minimum.

Note: A & B can contain positive/negative numbers.

How can you find this without sorting both arrays?

How can you find this by sorting both arrays?

- 0of 0 votes
How to partition an array of integers into subarrays so that the average of the two subarrays becomes equal, in efficient way?....

- 0of 0 votes
how to convert array into sub arrays

- 0of 0 votes
how to convert array into sub array so that we can access element from array into sub arrays in serial manner

- 0of 0 votes
explain with example when to use mutex and when to use semaphore

- -1of 3 votes
Given N,O where N=No. of digits that can be displayed on calculator and O=No. of multiplication to be performed.

The numbers used for the multiplication can be from {2,3,...8,9}

2<=N<=8

2<=O<=30

write function that will return the largest num that can be obtained after O multiplication.

Eg: N=2, O=3

the function should return 98, since the maximum no. generated after 3 multiplications 2*7*7.

function should return -1 for error or invalid.