Coding Interview Questions
- 0of 0 votes
AnswerHow Garbage collector know if something is not used and needs to be removed?
- Tom Walker June 07, 2015 in United States| Report Duplicate | Flag | PURGE
Ebay Software Developer Coding Compiler Debugging Java - 0of 0 votes
AnswersWhat's difference between Javascript and JAVA in terms of OOP principles. Provide examples.
- Tom Walker June 07, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Coding Java JavaScript Object Oriented Design - 0of 0 votes
AnswersDesign Bing search.
- Tom Walker June 07, 2015 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Developer Algorithm Coding Database Java Object Oriented Design Software Design - 0of 0 votes
Answers/*
- aj June 02, 2015 in United States
Tree:
1
/ \
3 5
/ \ \
2 4 7
/ \ \
9 6 8
==========
Expected Output:
1
35
247
968
*/
class TreePrinter {
static class Node {
int value;
Node left;
Node right;
public Node(int value, Node left, Node right) {
this.value = value;
this.left = left;
this.right = right;
}
}
public void printTree(Node root) {
// implementation here
}| Report Duplicate | Flag | PURGE
Linkedin Applications Developer Coding - 0of 0 votes
Answers/*Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die. Given a flowerbed (represented as an array containing booleans), return if a given number of new flowers can be planted in it without violating the no-adjacent-flowers rule
- aj June 02, 2015 in United States
Sample inputs
Input: 1,0,0,0,0,0,1,0,0
3 => true
4 => false
Input: 1,0,0,1,0,0,1,0,0
1 => true
2 => false
input: 0
1 => true
2 => false */
public boolean canPlaceFlowers(List<Boolean> flowerbed, int numberToPlace) {
// Implementation here
}| Report Duplicate | Flag | PURGE
Linkedin Applications Developer Coding - 1of 1 vote
Answersdesign a class (give different methods and variables that will be used) that will provide information about the allergy of a patient.
- katenaomi247 April 23, 2015 in United States
e.g. who reported the allergy(patient/doctor/relative), different symptoms of the allergy that are detected, severity, method that returns when was that
allergy detected in that patient. Along with info about disease if it is not allergy, and can be updated easily, how would you record the time of the disease report using java| Report Duplicate | Flag | PURGE
Cerner Corporation Software Engineer Coding Java Object Oriented Design - 0of 0 votes
Answers{1, 1, 0, 0, 0},
- sunnyg522 April 22, 2015 in United States
{1, 1, 0, 0, 0},
{1, 0, 0, 1, 1},
{0, 0, 0, 0, 0},
{1, 0, 1, 0, 1}
write a function to return the size of max cluster and coordinate of it, max cluster size to the above example is 5.| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 0of 0 votes
Answersgiven a string, characters can be shuffled to make a paliandrome.
What is the minimum possible number of insertions to original string needed so that it will be a palindrome (after shuffling, if required).Input
T -> number of test cases
T number of Strings in different linesimport java.util.Arrays; import java.io.InputStreamReader; import java.io.BufferedReader; public class Xsquare{ public static void main (String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int limit = Integer.parseInt(br.readLine()); int [] alphabets = new int[26]; while(limit-- >0){ String input = br.readLine(); Arrays.fill(alphabets,0); char [] inpChar = input.toCharArray(); int sum = 0; for (int i=0;i<input.length();i++){ int pos = (int)inpChar[i] - (int)'a'; alphabets[pos]+=1; } for(int i=0;i<26;i++){ if(alphabets[i]%2==0) sum+=0; else sum+=1; } if(sum<=0) sum=0; else sum-=1; System.out.println(sum); } } }
This is the code I submitted online. But it was not accepted as solution. What is the correct approach to this question?
- Kiran Vadakath April 21, 2015 in United States| Report Duplicate | Flag | PURGE
McAfee Applications Developer Coding - 0of 0 votes
AnswersGiven this set of interfaces:
- freedomsharp April 20, 2015 in United States
public interface Processor<T,U> {
U process(T arg);
}
public interface Splitter<T,V> {
V[] split(T arg);
}
public interface Worker<V,W> {
W processPart(V part);
}
public interface Aggregator<U,W> {
U aggregate(W[] args);
}
and this scenario:
Please provide
1. An implementation of Processor interface
2. Test cases for testing the implementation
http://webcache.googleusercontent.com/search?q=cache:QW8rjNE9dDwJ:stackoverflow.com/questions/29716343/how-to-implement-processort-u-using-java-generics+&cd=1&hl=en&ct=clnk&gl=in| Report Duplicate | Flag | PURGE
Morgan Stanley Associate Coding - 1of 1 vote
Answerswrite custom pattern match function to match following logic
.’ Matches any single character.
‘*’ Matches zero or more of the preceding element.
The matching should cover the entire input string (not partial).
The function prototype should be:
- storb99 April 07, 2015 in United Statesbool isMatch(const char *s, const char *p) Some examples: isMatch(“aa”,”a”) → false isMatch(“aa”,”aa”) → true isMatch(“aaa”,”aa”) → false isMatch(“aa”, “a*”) → true isMatch(“aa”, “.*”) → true isMatch(“ab”, “.*”) → true isMatch(“aab”, “c*a*b”) → true isMatch(“ccca”, “c*a”) → true
| Report Duplicate | Flag | PURGE
Yahoo Software Engineer Coding - 0of 2 votes
AnswersWrite a program to test whether a string and all strings that can be made using the characters of that string are palindrome or not.
- umang.agrawal91 April 02, 2015 in United States
Eg:
Input Output
mmo True
yakak True
travel False
Note : Please do not use any inbuilt functions.| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Coding - 4of 4 votes
AnswersSparse number is an integer if there are no adjacent 1 in it's binary representation.
- Rahul Sharma March 30, 2015 in United States
Like: 5 -> 101 (no adjacent 1)
9 -> 1001 (no adjacent 1)
while 6-> 110 is not sparse number.
Now you are given an integer find the NEXT BIGGER sparse number.Please mind 'it is next bigger'.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Coding - 0of 0 votes
AnswersWrite a program to modify the string in following pattern,
- qe.expert March 18, 2015 in India
Change odd words to uppercase and Reverse the even words. Make sure that the spaces (multiple) between the words remains as it is.
E.g.:
Input : "This is a test String!!"
Output: "THIS si A tset STRING!!"| Report Duplicate | Flag | PURGE
N/A Software Engineer in Test Coding - 0of 0 votes
Answershi i have one question, for example : convert A2B2A to A3B2, that is simple but but string can also have parentheses like AB3((CB)2(CB)2)3 which to converted to AB15C12
- anon March 18, 2015 in United States| Report Duplicate | Flag | PURGE
Coding - 0of 0 votes
AnswersYou are given heights of n candles .
- Rahul Sharma March 11, 2015 in India
First day you lit one candle
second day you need to lit two candles
Third day you need to lit three candles
..........
........
till possible.
After lighting candles the height of candles deduced by 1 each day.You can also extinguish any candle you want but only at the end of day.
So you need to tell the maximum number number of days , you can carry on lighting the candles.
Example : there are three candles of heights {2 , 2 ,2 }
Answer : 3
1.You light first candle on day one. heights -> {1,2,2}
2.You light second and third and extinguish first one . heights ->{1, 1,1}
3.You light all the candles. heights -{0,0,0}| Report Duplicate | Flag | PURGE
Google SDE-2 Coding - 0of 0 votes
AnswersInput any string, count the maximum depth of parenthesis nesting, i.e. "abc(123(xyz))m(((n)))o" -> 3.
- jobPrep February 23, 2015 in United States
if input is null or contains a mismatch "a)b(c" or "a(b"
Also some other samples:
(((()))) -> 4
()()()() -> 1| Report Duplicate | Flag | PURGE
Walmart Labs Coding - 1of 1 vote
AnswersConvert a binary tree into a In Order traversal circular list re-purposing the node's pointers Left & Right as Previous and Next respectively.
- Nelson Perez February 22, 2015 in United States
Hint: A single node Left & Right points to itself.
Note: This is not a binary search tree.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Coding - 0of 0 votes
AnswersWrite a function that takes an array of numbers and returns the maximum and minimum values.
- trophygeek February 21, 2015 in United States
Give BigO for runtime.
(This is a basic coding question. There are no real tricks or shortcuts.)| Report Duplicate | Flag | PURGE
Google Software Engineer Coding - 1of 1 vote
AnswersGiven a list of employees and their bosses as a text file , write a function that will print out a hierarchy tree of the employees.
- shalini.ravishankar February 08, 2015 in United States
Sample input =
Sam, Ian, technical lead, 2009 / Ian, NULL, CEO,2007/ Fred, Sam, developer, 2010
The format is name, supervisor, designation, year of joining
The output should be
Ian CEO 2007
-Sam Technical lead 2009
- -Fred Developer 2010| Report Duplicate | Flag | PURGE
Student Algorithm Coding Python - 0of 0 votes
Answers(Variant of Children-Sum Problem better than O(n^2))
- Rahul Sharma February 08, 2015 in India
Given a tree, implement a function which replaces a node’s value with the sum of all its childrens’ value, considering only those children whose value is less than than the main node’s value.
Eg: input = 60->50->80->40 , output = 90->40->40->0| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 0of 0 votes
AnswersGiven a function rev(int i) which reverses the segment of array ar[] from 0-i, Implement a function sort() using rev().
- Rahul Sharma February 07, 2015 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 Coding - 0of 0 votes
AnswersFind if a given number can be expressed in the form of p^q, where p and q are integers
- xyz_coder February 06, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Coding - 0of 0 votes
AnswersFind all palindromes in a given string. Single letters are also considered as palindromes.
- xyz_coder February 06, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Coding - 1of 1 vote
AnswersGiven a number A, find the smallest number which has only 1s and 0s as its digits which divisible by the number A. For example: if the given number A is 4, the smallest number with 1s and 0s is which is divisible by 4 is 100.
- xyz_coder February 06, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Arrays Coding - 2of 2 votes
Answers{{
- skc25pma February 02, 2015 in India
There are 3 machines M1, M2 and M3. Each machine is 90% full of its capacity with integers. Now you have to sort all the integers combined and then store the first 1/3rd in M1, second 1/3rd in M2 and last 1/3rd in M3.
Your objective is to minimize the number of sort operations and number of data transfer operations.
Each sort operation/data transfer operation is counted as 1 irrespective of the count of values that are being sorted/transferred.
}}| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Coding Sorting - 3of 3 votes
AnswersHow to find efficiently the minimum of an array of integers that is the maximum of other arrays?
- wingchun0511 January 31, 2015 in France
Example:
A = [126, 110, 130]
B = [125]
C = [105, 115]
The minimum element of array A that is the maximum of B and C is 126| Report Duplicate | Flag | PURGE
Java Developer Algorithm Coding Java Online Test - 0of 0 votes
AnswersWrite a function that takes a string as an input and outputs an integer, e.g. turning "1234" into 1234.
- americano- January 24, 2015 in United States for Cloud| Report Duplicate | Flag | PURGE
Microsoft SDET Coding - 0of 0 votes
AnswersJava coding
- an25081981 January 04, 2015 in India
Given a file with the following entry
ID EMp_Name Manager_ID
1 "ABC" 2
2 "PRW" Null
3 "DEF" 2
4 "PRE" 3
5 "DKF" 4
Print the Respective Manager hierarchy in the below format
PRW | ABC |
| DEF | PRE | DKF
The Employe Manager table can be extended to Hold N entry| Report Duplicate | Flag | PURGE
JP Morgan Java Developer Coding - 1of 1 vote
Answers1) You have a folder full of .bin files that are proprietary.
- haroldtreen January 03, 2015 in United States
2) You have a class called converter with a "binToTSV" method which you can pass the name of a .bin file and will generate a .tsv file.
3) The TSV file is a tab separated value file with a key on each line, and a value next to it spaced with a tab as such.
-------
num_connections 65
latency_ms 70
bandwidth 20
.... //etc.
-------
Q: Write a method to calculate the average latency and total bandwidth.| Report Duplicate | Flag | PURGE
Twitter Software Engineer / Developer Coding - 0of 0 votes
Answershow to design a relation functionality. similar to facebook , how to hold friends objects for a user profile , so that that is easily searchable . how to use cache for this?
- gopi.komanduri December 30, 2014 in India| Report Duplicate | Flag | PURGE
Adobe Computer Scientist Algorithm Coding Data Structures