AVK
BAN USER- 0of 0 votes
AnswersGiven two strings remove duplicates and test it
- AVK in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersGiven a function to reverse a linked list write code to test the function
- AVK in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 1of 1 vote
AnswersRemove common characters from two strings and print the common characters and test cases
- AVK in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 1of 1 vote
AnswersDelete m nodes for every n nodes in linked list and write the test cases
- AVK in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 6 votes
AnswersHow to find if a number is power of 4 in O(loglogn).
- AVK in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 0of 0 votes
AnswersWrite a program that breaks up a string of words with no spaces into a string of words with appropriate spaces
- AVK in United States| Report Duplicate | Flag | PURGE
- 1of 1 vote
AnswersGiven the amazon webpage, if you select any one item, you get recommendations down, for eg:- when I select a book, I get other book recommendations as well as movies related to the book, so If I now click on a movie, then I get something like popcorn which is related to movies, then I get food items as recommendations which is related to popcorn and so on.
- AVK in United States
So how do find how many clicks it takes to reach a particular item? for eg:- from a book to a pizza| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersGiven a community of people, find out a person who could be a potential mayor. Constraints as below.
- AVK in United States
1) Mayor does not know any of the people in the community.
2) All the people in the community must know the mayor, that is he has to popular.
My apologies, I forgot to mention that the interviewer had also given me a function called " knows(int a, int b) " that returns a boolean value if a knows b.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
Answerscreate a mirror of a binary tree.
- AVK in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersGiven a string of text, group all the words such that anagrams are stored and returned together in groups.
- AVK in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersRemove duplicates in a string.
- AVK in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - -5of 5 votes
AnswersFind the shortest path between two nodes in a graph, given only the start node and the end node as parameters.
- AVK in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 1of 1 vote
AnswersGiven an 8x8 chess board, you have a bishop that moves from the current to the target position. write a code to find the minimum path from the current to the target position.
- AVK in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm
Base class button{
//common setters and getter variables
//common methods declared abstract and called virtually
}
class channel extends button {
//channel specific getters and setters and methods
}
class volume extends button {
//volume specific getters and setters and methods
}
class power extends button{
//power specific getters and setters and methods
}
//Not sure of the below two.
class battery{
}
class remote{
}
public static int checkHeight(TreeNode root){
if(root==null){
return 0;
}
//check if left is balanced
int leftHeight = checkHeight(root.leftChild());
if(leftHeight==-1){
return -1;
}
//check if right is balanced
int rightHeight = checkHeight(root.rightChild());
if(rightHeight==-1){
return -1;
}
//checks if the current TreeNode is balanced
int height = leftHeight - rightHeight;
System.out.println(height);
if(Math.abs(height)>1){
return -1;
}else{
return Math.max(leftHeight, rightHeight)+1;
}
}
void mirrorTree(TreeNode root){
//
if(root == null)
return;
mirrorTree(root._leftChild);
mirrorTree(root._rightChild);
if(root._leftChild!=null){
root._leftChild._rightChild = root;
root._leftChild = null;
}
if(root._rightChild!=null){
root._rightChild._leftChild = root;
root._rightChild = null;
}
}
So in this case, we can use the function retainAll(java.util.Collection c) which removes all elements which is not in collection c and retains only the elements that are present in the first bag. So, now iterating through the second bag gives the common elements. Please go let me know if this approach would be appropriate...
- AVK September 28, 2013We could use a BFS, visit every node and add sum of the integers to the master map that has all the URL's checking, if the URL is already present, then just add the integer orelse create a new key and put it into the map. Then traverse through the map to find the top ten values or just sort descending and return the first 10 values.
- AVK September 27, 2013
How do you do in Java
- AVK November 02, 2013