Java Developer Interview Questions
- 0of 0 votes
AnswersGiven a BST convert it into new Data Structure that satisfies following conditions:
1. every leaf node's left ptr point to its parent and right ptr points to the next leaf
2. every non leaf node's left ptr points to its parent and right ptr is NULL
3. return the head and print the new DSexample: 7 / \ 5 9 / \ \ 4 6 10 output: head->4->5->7 | ->6->5->7 | ->10->9-7
with optimal time and space complexity
- ajay.raj March 05, 2018 in United States| Report Duplicate | Flag | PURGE
Amazon Java Developer - 0of 0 votes
Answersinput: "kitten%20pic.jpg"
- ajay.raj March 05, 2018 in United States
output: "kitten pic.jpg"
%20 -> ' '
%3A -> '?'
%3D -> ':'
modify your input in place.
no string library functions.
void Decode(char[] str)| Report Duplicate | Flag | PURGE
Amazon Java Developer - 0of 0 votes
AnswersGiven a string T of length n, partition it in n' "phrases" (p1, p2, ..., pn'),
- ajay.raj March 05, 2018 in United States
such that
pi = pj + c, for some j<i, where + is string concatenation and c is a character
p0 = ''
p1 = pj + c where j < 1
T = p1 + p2 + ... + pn'
For example:
T = aababcabcd = a + ab + abc + abcd
p1 p2 p3 p4| Report Duplicate | Flag | PURGE
Amazon Java Developer - 0of 0 votes
AnswersPrint a binary tree in vertical order using singly linked list...
- ajay.raj March 05, 2018 in United States| Report Duplicate | Flag | PURGE
Amazon Java Developer - 0of 0 votes
Answersfind a points that has same distance to given three points
- ajay.raj March 04, 2018 in United States| Report Duplicate | Flag | PURGE
Amazon Java Developer - 0of 0 votes
Answersinput is an int [] number is the car number parked in the parking lot, 0 for empty spaces
- ajay.raj March 04, 2018 in United States
Output is also an int [] requires a method to convert the input into target array.
Each car can only be exchanged with a 0.| Report Duplicate | Flag | PURGE
Amazon Java Developer - 0of 0 votes
Answers
- ajay.raj March 04, 2018 in United StatesGiven a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": great / \ gr eat / \ / \ g r e at / \ a t To scramble the string, we may choose any non-leaf node and swap its two children. For example, if we choose the node "gr" and swap its two children, it produces a scrambled string "rgeat". rgeat / \ rg eat / \ / \ r g e at / \ a t We say that "rgeat" is a scrambled string of "great". Similarly, if we continue to swap the children of nodes "eat" and "at", it produces a scrambled string "rgtae". rgtae / \ rg tae / \ / \ r g ta e / \ t a We say that "rgtae" is a scrambled string of "great". give a string s, print all the scrambled string of it class Solution { public List<String> ScrambleString(String s) { } }
| Report Duplicate | Flag | PURGE
Amazon Java Developer - 0of 0 votes
AnswersDesign a dictionary with historical records
- ajay.raj March 01, 2018 in United States
t0: hdict = HistoricalDict ()
t2: hdict.set ('foo', 1)
t4: hdict.set ('foo', 2)
t5: hdict.get ('foo', t5) -> 2
t6: hdict.get ('foo', t3) -> 1
t7: hdict.get ('foo', t0) -> None| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
AnswersCSS colors can be defined in the hexadecimal notation "#rgb", a shorthand for "#rrggbb". For example, "#03f" is equivalent to "#0033ff". Suppose the similarity between two colors "#abcdef" and "#ghijkl" is defined as (-(ab-gh)^2 - (cd-ij)^2 - (ef-kl)^2), write a function that accepts a color in the "#abcdef" format and returns a "#rgb" color that is most similar to the input. For example, given "#09f166", "#1e6" should be returned.
- ajay.raj March 01, 2018 in United States| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
Answers
- ajay.raj March 01, 2018 in United StatesGiven a binary tree, output the maximum EVEN sum along any path 10 / \ 2 5 / \ \ 1 101 13 Maximum even sum = 101 +2 +10 + 5 = 118
| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
Answersconvert a Sorted linkedList to complete BST
- ajay.raj February 23, 2018 in United States| Report Duplicate | Flag | PURGE
Google Java Developer - -1of 1 vote
AnswersGiven list of edge in the graph, find the number of reversed pairs,(1,2)
- ajay.raj February 21, 2018 in United States
and (2,1) are such pair. Follow up: How to implement the distributed version.| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
AnswersAn n * m matrix represents an array of computers, giving you a List <int []> that represents the coordinates of the broken computer.
- ajay.raj February 18, 2018 in United States
Now we start from (0,0) repair computer requirements:
1. You must finish all the broken computers in the current line to get to the next line
2. To go to the next line, the mechanic must first return to the far left or right of this line
And then find repair each computer order that has the minimum access distance,| Report Duplicate | Flag | PURGE
Google Java Developer - -1of 1 vote
AnswersA robot can only be moved one step to the right (x + 1) at a time while moving upward or downward or horizontally (y-1, y + 1, y) , given the starting and ending positions, and a series of points must pass, ask how many kinds of ways from start to end.
- ajay.raj February 17, 2018 in United States| Report Duplicate | Flag | PURGE
Google Java Developer - -1of 1 vote
AnswersDetermine whether the inorder of n binary trees is the same
- ajay.raj February 14, 2018 in United States| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
AnswersGive you a csv file There are three columns are id, parent, weight Then give you a class Node which has these three fields
- ajay.raj February 14, 2018 in United States
But you also have the option of adding more fields for you to print out all the node's subwebs.
The definition of subweight is the sum of the node's weight plus the subweight of his children.| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
AnswersGive a chessboard, check if a group of white chesses are surrounded by all black chesses.
- ajay.raj February 14, 2018 in United States| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
AnswersGiven a list of relationship of report
- ajay.raj February 13, 2018 in United States
A reported to D, D reported to Z, who are reported to Z| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
AnswerGive the structure of a directed graph
- ajay.raj February 13, 2018 in United States
START -> a -> b -> c -> END
If a word can start from start and end at END, then we think the word is in this diagram
For example, the string "abc" is consistent, but "ab" does not match,
Although "ab" is also inside the graph, b's next is "c" instead of END, so it's not legal word
(Note: each node can have more than one next)
1. According to the problem, design the data structure
Write a function, input is START and a string, to determine whether the string is a valid word
3. follow up, if the graph has cycle, how to do?
4. If the graph has repeated characters how to do?| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
Answershow to check is a small matrix appear in a big matrix
- ajay.raj February 12, 2018 in United States
boolean isSubmatrix(int[][] small, int[][] big)| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
AnswersYou have to cut a wood stick into pieces. The most affordable company, The Analog Cutting Machinery,
- ajay.raj February 12, 2018 in United States
Inc. (ACM), charges money according to the length of the stick being cut. Their procedure of work
requires that they only make one cut at a time.
It is easy to notice that different selections in the order of cutting can led to different prices. For
example, consider a stick of length 10 meters that has to be cut at 2, 4 and 7 meters from one end.
There are several choices. One can be cutting first at 2, then at 4, then at 7. This leads to a price
of 10 + 8 + 6 = 24 because the first stick was of 10 meters, the resulting of 8 and the last one of 6.
Another choice could be cutting at 4, then at 2, then at 7. This would lead to a price of 10 + 4 + 6 =
20, which is a better price.
Your boss trusts your computer abilities to find out the minimum cost for cutting a given stick.| Report Duplicate | Flag | PURGE
Google Java Developer - 1of 1 vote
AnswersGiven an aray with ['a1', 'a2', .....'aN', 'b1', 'b2', ....'bN', 'c1', 'c2', .....'cN'],
- ajay.raj February 10, 2018 in United States
stagger the subarrays so it becomes ['a1', 'b1', 'c1', 'a2', 'b2', 'c2', ...'aN', 'bN', 'cN']. The optimal solution requires linear-time
sorting and a constant space complexity.| Report Duplicate | Flag | PURGE
Facebook Java Developer - 0of 0 votes
AnswerHow to design a spreadsheet program? How do you know to update a field after another
- ajay.raj February 10, 2018 in United States
field was changed that it depended on?| Report Duplicate | Flag | PURGE
Facebook Java Developer - 0of 0 votes
AnswersGiven a set of points in the 2D coordinate system, find the radius of the
- ajay.raj February 10, 2018 in United States
smallest circle which encompasses
all the given points| Report Duplicate | Flag | PURGE
Facebook Java Developer - 0of 0 votes
AnswersTry to come up with a combination of two data structures to implement a
- ajay.raj February 10, 2018 in United States
data structure that supports search,
delete in O(1) time and insert in O(n) time.Try to come up with a combination of two data structures to implement a
data structure that supports search,
delete in O(1) time and insert in O(n) time.| Report Duplicate | Flag | PURGE
Facebook Java Developer - 0of 0 votes
AnswersIt was asked in Chargebee off campus interview. Needed solution for this problem in java
- psribalaji12 February 08, 2018 in India
Given a string say s and k denotes the number of commas and the output should be like when you insert the comma in the string at different places and find the maximum number.
Test case 1
say s = 999 and k = 1 so the choice would be 9,99 or 99,9 in either case the maximum number is 99
Test case 2
say s=999 and k =2 so the choice will be like 9,9,9 so output will be 9
Test case 3
say s = 857 and k = 1 the choice would be 85,7 or 8,57 so the output will be like 85| Report Duplicate | Flag | PURGE
StartUp Java Developer Arrays Brain Storming String Manipulation - 0of 0 votes
AnswersImplement a grep-like function. For example
- ajay.raj February 01, 2018 in United States
[A1 + A2, B1 + B2, C1], grep (A = A1), is to return the result that contains A1,
For example, [A1, B1, C1], [A1, B2, C1].
More tricky can be grep (A = A1, A2, B = B1), so that is included (A1 || A2) & B1.| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
AnswersGiven an array {a0, a1, a2, ... an, b0, b1, b2 ... bn},
- ajay.raj February 01, 2018 in United States
Rearrange this array into {a0, b0, a1, b1, a2, b2, ... an, bn}
inplace, O (1) space| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
AnswersGive you a bunch of light bulbs. Can flip a range of open change off, turn off open, and then asked to do so k times later, just ask you a light bulb is turned on or turned off, how to do
- ajay.raj January 31, 2018 in United States| Report Duplicate | Flag | PURGE
Google Java Developer - 0of 0 votes
Answer*e*er -> peter
- ajay.raj January 31, 2018 in United States
**eue -> queue
**o
ma*
*p*a*e*
*erso*
***k*am*on
*ouse
*a*
*ur*
***igent
where there are 26 *, and we can fill all the stars in to form valid english words while using each letter once. Given this array and a dictionary how would you fill all the words in?| Report Duplicate | Flag | PURGE
Google Java Developer