intervyou
BAN USER 3of 3 votes
AnswersStarting at the 0 (zero) index, you need to "jump" through a onedimensional array (zero based index) of true/false values. True is a place you can land on (if desired) and false is a place you must jump over (cannot land on). The array can be very very long.
 intervyou in United States
Your "velocity" indicates how many spots (or array indexes) you advance with every jump. For example, if you have a velocity of 2 and are currently at index 4, after the jump, you will be at index 6. Before each jump you can increase your velocity by 1, decrease your velocity by 1, or keep the same velocity. You can only go forwards.
You start at index 0 (zero), with a velocity of 1. This means that for the very first jump, you can keep the same velocity and move to index 1, or increase velocity by 1 (to a velocity of 2) to move to index 2. On this first jump, you can't decrease your velocity as that would make your velocity 0 (zero) and you wouldn't move. Now that you've jumped, you can again increase, decrease, or keep your velocity the same, then jump again.
As an example, let's say you increased your velocity to 2 and jumped. You're now at index 2 with a velocity of 2. You can:
1) decrease your velocity to 1 and jump to index 3.
2) keep your velocity at 2 and jump to index 4.
3) increase your velocity to 3 and jump to index 5.
Remember, you can only and on an index if it's "true". You are successful if you can get past the last index. Implement a function to determine if the rabbit can make it across given the field (array).
Here is a field that the rabbit cannot cross:
$field = array(true, true, false, true, false, true, false, false, false, true);
Here is a field that the field can cross:
$field = array(true, true, false, true, false, true, true, false, false, true, false); Report Duplicate  Flag  PURGE
Algorithm  0of 0 votes
AnswersFind the maximum sum subset in an array with negative integers
 intervyou in United States Report Duplicate  Flag  PURGE
Linkedin Software Engineer / Developer  0of 0 votes
Answersfind the Maximum product subset with negative and positive integer
 intervyou in United States Report Duplicate  Flag  PURGE
Linkedin Software Engineer / Developer  0of 2 votes
AnswersObjective: Write a function to find all the combinations of three numbers that sum to zero
 intervyou in United States
Sample input:
[2, 3, 1, 2, 1, 0, 2, 3, 0]
Sample output:
2, 2, 0
1, 1, 0
3, 2, 1
3, 0, 3
3, 0, 3 Report Duplicate  Flag  PURGE
Twitter Software Engineer / Developer Algorithm  1of 1 vote
Answerswrite a function that has an int as input and return the equivalent String as an output
 intervyou in United States
12 > 'twelve'
4345 > 'four thousand three hundred and fortyfive'
7654567643 > 'seven billion six hundred and fiftyfour million five hundred and sixtyseven thousand six hundred and fortythree' Report Duplicate  Flag  PURGE
Twitter Software Engineer / Developer Algorithm
public class findAncestor implements FirstCommonAncestor{
public Node commonAncestor(Node one, Node two){
///
int depth1 = findDepth(one);
int depth2 = findDepth(two);
///
if(one == null  two == null){
return null;
}else if(one.isRoot){
return one;
else if (two.isRoot){
return two;
}
return findCommonAncestor(one, two,depth1,depth2);
}
public findCommonAncestor(Node one,Node two,int depth1, int depth2);
if (depth1 == depth2){
if(one.parent == two.parent){
return one.parent;
}else
return one.parent.parent;
}
else if (depth1 > depth2){
one = one.parent;
findCommonAncestor( one, two, depth1  1, depth2);
}else
two = two.parent
findCommonAncestor( one, two,int depth1, depth2  1);
}
}
public int findDepth(node n){
if(n.isRoot){
return 0;
}
return 1 + depth(root.parent);
}

intervyou
May 16, 2014 Open Chat in New Window
 intervyou June 02, 2014