Developer Program Engineer Interview Questions
- 0of 0 votes
Answerssuppose john has been give task of monitoring a radio which is jumping to random frequency on a hourly basis. joha has to find the maximum positive frequency difference of that radio in at most two selections.
- sarath.chalasani46 August 10, 2015 in India
examples :
1. suppose radio is tuned to 91MHz to 98MHz and then to 95MHZ.
In first tunning Df= f2-f1 =98-91=7 (positive frequency diff)
In second tunning Df= f2-f1 =95-98=-3 (negative frequency diff)
2. Input1: {,30,15,10,8,25,80}
input2: 7
output:100
To have maximum frequency diff with at most two selections. john has to select 2MHZ and he has to drop it to 30MHZ and second selection, he has to pick 8MHz to 80Mhz.
so output is 28+72=100| Report Duplicate | Flag | PURGE
ADP Developer Program Engineer - 0of 0 votes
AnswersPassing objects and correct the program:---
- Avinash July 14, 2015 in United States
class OdemoA
{
int i,j;
void function1(int i)
{
System.out.println(i);
System.out.println("Inside function()");
}
void function2(Area a1)
{
if(a1!=null)
{
a1.i=203;
a1.j=115;
}
System.out.println(a1);
System.out.println("end of function2()");
}
public static void main(String args[])
{
OdemoA d1 = new OdemoA();
Area a2 = new Area();
d1.function2(a2);
System.out.println(a2.i);
System.out.println("end main");
}
}| Report Duplicate | Flag | PURGE
ADP Developer Program Engineer Java - -1of 1 vote
AnswersI realized this algorithm for generating combinations. It works in the following way, if we have the input:
- pasquale.restaino1992 July 11, 2015 in United States
[A, B, C]
The combinations will be
[A], [B], [C]. [A, B], [A, C], [B, C], [A, B, C].
While if we have in input:
[1,1,2,3]
The combinations will be:
[1], [2], [3], [4], [1,2], [1,3], [2,3 ], [1,1,2,3].
However, this algorithm has a running time of good only when the input is a list of size 4, if the list is of size 5 or more (when there are 5 different elements ( for example 80 A, 150 B , 80 C , 30 D , 20 E)) the program stops and gives me java.lang.OutOfMemory (I increased the memory for in java). One problem could be the fact that I have used LinkedList, but I'm not sure.
Is there a better solution?
private List<Elemento> combinazioneMassima = new ArrayList<>();
private Log logger = LogFactory.getLog(Combinazioni3.class);
public Combinazioni3(List<Elemento> generaCombinazioneMassima) {
this.combinazioneMassima = generaCombinazioneMassima;
}
public void combine() {
this.findAllCombinations(combinazioneMassima);
}
private static class Node{
int lastIndex = 0;
List<Elemento> currentList;
public Node(int lastIndex, List<Elemento> list) {
this.lastIndex = lastIndex;
this.currentList = list;
}
public Node(Node n) {
this.lastIndex = n.lastIndex;
this.currentList = new ArrayList<Elemento>(n.currentList);
}
}
public void findAllCombinations(List<Elemento> combinazioni) {
Date dataInizio = new Date();
List<List<Elemento>> resultList = new ArrayList<List<Elemento>>();
LinkedList<Node> queue = new LinkedList<Node>();
int n = combinazioni.size();
ArrayList<Elemento> temp = new ArrayList<Elemento>();
temp.add(combinazioni.get(0));
queue.add(new Node(0, temp));
// add all different integers to the queue once.
for(int i=1;i<n;++i) {
if(combinazioni.get(i-1) == combinazioni.get(i)) continue;
temp = new ArrayList<Elemento>();
temp.add(combinazioni.get(i));
queue.add(new Node(i, temp));
}
// do bfs until we have no elements
while(!queue.isEmpty()) {
Node node = queue.remove();
if(node.lastIndex+1 < n) {
Node newNode = new Node(node);
newNode.lastIndex = node.lastIndex+1;
newNode.currentList.add(combinazioni.get(node.lastIndex+1));
queue.add(newNode);
}
for(int i=node.lastIndex+2;i<n;++i) {
if(combinazioni.get(i-1) == combinazioni.get(i)) continue;
// create a copy and add extra integer
Node newNode = new Node(node);
newNode.lastIndex = i;
newNode.currentList.add(combinazioni.get(i));
queue.add(newNode);
}
GestoreRegole gestoreRegole = new GestoreRegole();
gestoreRegole.esegui(node.currentList);
}
}| Report Duplicate | Flag | PURGE
Developer Program Engineer Algorithm - -1of 1 vote
AnswersI realized this algorithm for generating combinations. It works in the following way, if we have the input:
- pasquale.restaino1992 July 11, 2015 in United States
[A, B, C]
The combinations will be
[A], [B], [C]. [A, B], [A, C], [B, C], [A, B, C].
While if we have in input:
[1,1,2,3]
The combinations will be:
[1], [2], [3], [4], [1,2], [1,3], [2,3 ], [1,1,2,3].
However, this algorithm has a running time of good only when the input is a list of size 4, if the list is of size 5 or more (when there are 5 different elements ( for example 80 A, 150 B , 80 C , 30 D , 20 E)) the program stops and gives me java.lang.OutOfMemory (I increased the memory for in java). One problem could be the fact that I have used LinkedList, but I'm not sure.| Report Duplicate | Flag | PURGE
Developer Program Engineer Algorithm - 0of 0 votes
AnswersThis is a sample program to find the maximum contiguous sum in an array.
int maxSubArraySum(int a[], int size) { int max_so_far = a[0], i; int curr_max = a[0]; for (i = 1; i < size; i++) { curr_max = max(a[i], curr_max+a[i]); max_so_far = max(max_so_far, curr_max); } return max_so_far; }
Now modify this to print the start and end indices.
- Anand Barnwal July 09, 2015 in India| Report Duplicate | Flag | PURGE
Adobe Developer Program Engineer Algorithm - 0of 0 votes
Answerswrite a java program display the sub string from a string without using string function
- vivek260394 June 11, 2015 in India for 1| Report Duplicate | Flag | PURGE
Developer Program Engineer Java - 0of 0 votes
Answersgiven an array with elements check if just by exchanging two elements of the array we get a sorted array.
- venuskoti June 10, 2015 in India for xyz| Report Duplicate | Flag | PURGE
xyz Developer Program Engineer Arrays - 0of 4 votes
Answersyou have a stream of bytes (1010101101011110100010......)to send over the net. but if you compress it. you will be charged less for less data usage. please try to compress it in a way that you can decompress at other end ahd you dont loss data
- coinsofakshay May 11, 2015 in United States| Report Duplicate | Flag | PURGE
Google Developer Program Engineer Algorithm - -1of 1 vote
Answersconsider a battlefield to be made up of square cells of unit dimensions. a soldier on the battlefield can move from a cell to all(8) of it's neighboring cells. soldier has a gun with with him which he can shoot the targets up to any distance along any of the 8 possible directions (north,east,west,south,north-east,north- west,south- east,south- west). also some sell are bulletproof which prevents bullets to pass but soldier can walk over them as if it were a normal cell.he can destroy the target from a bulletproof cell but not from a cell behind it.
- sarath.chalasani46 May 03, 2015 in India for dev
position of a target/ soldier can be given by the cell, they are on.given the position of the target, starting position of a target and position of all the bullet proof cells. you have to tell the position of closest shooting point i.e the cell from which, the soldier can shoot the target and is closest to the starting position of the soldier. if there are more than such cells, output all of them.
Input/output specifications :
Input specifications :
I) size of the battlefield { integer pair (N,M) : battlefield will be of N*M size )
II) staring position of the soldier {integer pair (i,j)}
III) position of the target {integer pair (x,y) : position of the cell on which target is mounted}
IV) position of the all bullet proof cells { list of integer pair a#b : each element in the list is a position of bullet proof cells }
output specifications :
sequential list of integer pair i#j (cell) that are closest shoot points and must fallow row wise traversal.
Note: if the output list contains four shoot points : (2,1), (1,2), (3,2), (2,4) on a 4x4 battle field.
then the correct output will be {1#2,2#1,2#4,3#2} not {1#2,2#1,3#2,2#4}
Examples:
Input : {2,2} {2,1} {2,2} {1#1,1#2}
output : 2#1
below is the method signature in java:
public static String[] nearest_shoot_point(int[] input1,int[] input2,int[] input3String[] input4){
}| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer Java - 0of 0 votes
AnswersGiven a 2 dimensional point of a rectangle and its area, find permutations of all the other 3 points of the rectangle in 2-D space.
- shffan2010 April 29, 2015 in United States
Ex:- Given X=(0,0) and A=1
(0,1),(1,0),(1,1)
(0,-1),(-1,0),(-1,-1)| Report Duplicate | Flag | PURGE
Epic Systems Developer Program Engineer - 0of 0 votes
Answersglitch is a walking robort moves in a peculiar problem: it takes x steps forward , then x+1 steps backward, then 2x steps forward, x+2 steps backward,3x steps forward x+3 steps backward , and so on... until it has taken y steps,glitch turns 180 degrees before continuning with its pattern . write a program that prompts x and y and total number of steps taken and outputs how many steps away from its starting point
- shffan2010 April 29, 2015 in United States| Report Duplicate | Flag | PURGE
Epic Systems Developer Program Engineer - 0of 0 votes
AnswersGiven a password in number : Write an algorithm to print all possible combinations of that password.
- shffan2010 April 29, 2015 in United States
Hint: - Try to go from all possible combinations of lower bound to the valid upper bounds| Report Duplicate | Flag | PURGE
Epic Systems Developer Program Engineer - 0of 0 votes
AnswersBasket ball hit rates The hit rate of the basketball game is given by the number of hits divided by the number of chances. For example, you have 73 chances but hit 15 times,
- shffan2010 April 29, 2015 in United States
then your hit rate is 15/73=0.205 (keep the last 3 digits). On average, you have 4.5 chances in each basketball game. Assume the total number of games is 162. Write a function for a basketball player. He will input the number of hits he has made, the number of chances he had, and the number of remaining games. The function should return the number of future hits,
so that he can refresh his hit rate to 0.45| Report Duplicate | Flag | PURGE
Epic Systems Developer Program Engineer - 0of 0 votes
Answersget a string(word) from user, then make every possible permutation words.
- Tony April 16, 2015 in United States
Ex)intput: tree => output : tree, rtee, rete, reet, etre, eetr, eert, eter, eret, teer, reet..| Report Duplicate | Flag | PURGE
Epic Systems Developer Program Engineer Algorithm - 0of 0 votes
Answerssecurity code takes numbers but one key is allowed to be faulty, other numbers should be same in sequence ex 124 is accepted if actual number is 126 46..
- Tony April 16, 2015 in United States| Report Duplicate | Flag | PURGE
Epic Systems Developer Program Engineer Algorithm - 0of 0 votes
Answersyou can go to a fast food restaurant to buy chicken nuggets in 6-pack, 9-pack or 20-packs. is there such a number N, such that for all numbers bigger than or equal to N, you can buy that number of chicken nuggets?
- Tony April 16, 2015 in United States| Report Duplicate | Flag | PURGE
Epic Systems Developer Program Engineer Algorithm - 0of 0 votes
AnswersThis is on Additive Number Property
- Tony April 16, 2015 in United States
Additive Number examples:
123459 (1+2=3, 4+5=9)
314538 (3+1=4, 5+3=8)
122436 (12+24=36)
You are given a range, you need to print all the additive numbers.| Report Duplicate | Flag | PURGE
Epic Systems Developer Program Engineer Algorithm - 0of 0 votes
AnswersSimplify the implementation below as much as you can.
- noam.nta April 12, 2015 in United States
Even better if you can also improve performance as part of the simplification!
FYI: This code is over 35 lines and over 300 tokens, but it can be written in
5 lines and in less than 60 tokens.
קוד: בחר הכל
static int func(String s, char a, char b)
{
if (s.isEmpty()) return -1;
char[] strArray = string.toCharArray();
int i=0;
int aIndex=0;
int bIndex=0;
while (aIndex=0 && bIndex==0 && i<strArray.length)
{
if (strArray[i] == a)
aIndex=i;
if (strArray[i] == b)
bIndex=i;
i++;
}
if (aIndex != 0)
{
if (bIndex == 0)
return aIndex;
else
return Math.min(a, b);
}
else
{
if (bIndex != 0)
return bIndex;
else
return -1;
}
}| Report Duplicate | Flag | PURGE
Google Developer Program Engineer - 0of 0 votes
AnswersGiven 1 byte. Write a function that checks that it have exactly 3 bits which equal to 1.
- noam.nta April 12, 2015 in United States| Report Duplicate | Flag | PURGE
Google Developer Program Engineer - 0of 2 votes
AnswersI needed to develop next system:
- Stanand April 05, 2015 in United States
We have a lot of servers. Every server generate logs. Every log has two data types: first is numeric metrics. These numeric metrics are integer. Second is strings. We need to collect logs from all servers on other server (storage). Then we have to execute queries and get some data from storage. In our queries we have to use numeric metrics and strings as well. For numerics metrics we have to be able get aggregation data as well.
Develop Storage server, database. Describe how will you scale this system, what database will you use, how will you save data and how will you execute this queries.| Report Duplicate | Flag | PURGE
Facebook Developer Program Engineer Distributed Computing - 0of 0 votes
AnswersC program given two strings and print common character from both:
- genny April 01, 2015 in India
Input: bangalore
mysore
output: ore| Report Duplicate | Flag | PURGE
Adobe Developer Program Engineer - 1of 1 vote
AnswersGraph problem:
- manidam07 March 30, 2015 in India
Critical node: If a node reaches another node only through one node.
Eg: A-C-B and A-E-B are critical nodes. (A reach B through one node which is C or E)
If A reaches B through more than one node, then they are not critical nodes.
1) A-C-B
A-D-E-B (A reach B thro C which might lead to critical node but A has another path to B thro D and E, so they are not critical nodes).
2) X-Y-Z
X-A-Z (X and Z are critical nodes)
Now find all critical nodes.| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer Algorithm - 0of 0 votes
AnswersI have a 4 simple thread T1, T2, T3, T4, is there any way we can find out which thread will execute first each time.
- shoeb JD March 06, 2015 in India| Report Duplicate | Flag | PURGE
Ness Developer Program Engineer - 0of 0 votes
AnswersMr. Xhas recently shut down his factory and wants to sell off his metal rods to a local businessman. Mr. Octopus has many rods whose length are represented by array - lengths = {lengths[0], lengths[1], lengths[2], ...}.
- rashmishrikant.patil February 05, 2015 in India
The local businessman will only pay for rods that have same length. Let's say Mr. Octopus plans to sell rods of lengthL only. Then he had to cut each rod 0 or more time, so that he can maximize the profit. The remaining rods whose length is not L will be thrown away. Price of N rods of length L will be N × L × unit_price. Also note that for each cut made to a rod, he had to pay cut_cost.
What is the maximum amount of money Mr. Octopus can make? You have to complete the function int maxProfit(int cut_cost, int unit_price, int[] lengths).
Constraints
• lengths will contain between 1 to 50 elements, inclusive.
• Each element of lengths will lie in range [1, 10,000].
• 1 ≤ unit_price, cut_cost ≤ 1,000.
Sample Input #1:
cut_cost = 1
unit_price = 10
lengths = [26, 103, 59]
Sample Output #1:
1770| Report Duplicate | Flag | PURGE
Oracle Developer Program Engineer Algorithm - 1of 1 vote
AnswerHow do you design system for identifying groups of contacts in phone. Basic info like mail Id, name are different but the person representing them is same. looking for a deduplication way to identify.
- Vib February 05, 2015 in India| Report Duplicate | Flag | PURGE
Boomerang Commerce Developer Program Engineer Object Oriented Design - 0of 0 votes
AnswersImplement method to print left view of binary tree.
- Vib February 05, 2015 in India| Report Duplicate | Flag | PURGE
Boomerang Commerce Developer Program Engineer Algorithm - 0of 0 votes
AnswersFrom a web page, each logged in user can click on a plus icon and enter key-value pairs. There is restriction on the entered key and values. Design a schema to store the enter the key-value pairs entered by each user, such that given a key we should be able to retrieve all the username who entered that particular key.
- vinodjayachandran February 03, 2015 in India| Report Duplicate | Flag | PURGE
StartUp Developer Program Engineer Database - 0of 0 votes
AnswersIEEE float to IBM float value conversion
- gsuit123 February 03, 2015 in United States| Report Duplicate | Flag | PURGE
Yahoo Developer Program Engineer