Loler
BAN USER- 1 Answer Questions deleted by OP?
I have noticed that a couple of questions have been deleted. (One was a very new maximum product sub-array question, and one was a relatively new zig-zag of a 1-D array, which has a nice answer by showell).
- Loler March 10, 2013
It seems unlikely that the mods are deleting those, as those seemed like valid questions.
Is it possible that the OP deleted them after getting an answer? (Possibly homework and didn't want to get caught...).
Is there are a way to get back the questions (and the answers)? Prevent such things from happening in the future? (Eg. Don't allow a delete of a question after 2-3 answers have been posted).| Flag | PURGE
@jean. That is what people have _interpreted_ it to be. Which IMO, is a totally bogus interpretation. If you want to put the characters in a BST, then isn't it reasonable to assume you want to make the character the key?
Usually interview questions have the scope for the candidate to show a logical thought process. btw, if the interviewer was only interested in BST+coding, do you really think the interviewer could not find anything better than such a borderline nonsensical question?
Making the index the key, is just arbitrary. In fact, making it a BST like that (using the position) gains you what exactly? Leaving it as an array is much better if you want to lookup etc.
More likely, the person who posted on Glassdoor was completely clueless and had no idea what the interviewer was asking, and posted some nonsense, which Bevan chose to post here.
That is what is annoying about some of problems posted here. They are just incomplete and bordering on the nonsensical (at least from a practical programming interview question point of view).
What makes it funny(and annoying at the same time) is people seem to delude themselves by posting and upvoting trivialities (I guess this might make me sound arrogant). If people are interested in getting a job at a good company, they should learn to be critical of their solutions and give the questions themselves some credit. Coming up with nonsensical/trivial interpretations will easily get you a reject.
That was a long rant. Sorry.
Traverse in reverse in-order (i.e. descending order).
Something like this (quick code without thinking, so bugs will be there).
Tree * Largest(Tree *root, const int k) {
int count = 0;
return LargestHelper(root, k, count);
}
// Return either NULL (not found), or returns the node.
Tree *LargestHelper(Tree *root, const int k, int &count) {
if (root == NULL) {
return NULL;
}
Tree *right = LargestHelper(root->right, k, count);
if (right != NULL) return right;
count++;
if (count == k) {
return root;
}
return LargestHelper(root->left, k, count);
}
Few things
1) It is not correct. For instance, if adef is the long string and bc is the string sought, then you will say true, while it is clearly false. (Basically a+d = b+c)
Basically, sum being same does not imply you have gotten your string.
2) For long strings there is a good chance of overflows, and messing up your results even more, 1) not withstanding.
3) The runtime of this is O(|A||B|) where the string lengths are |A| and |B|.
(I should have stated, 2 and 3 are no biggies, but being incorrect is).
While they might ask algorithm questions, they are looking at how you attack the problem. This is not the same as testing your algorithm skills. You are not expected to come up with the optimal solution, nor is it necessarily a bad sign if you don't come up with one.
Since programmers are expected to be familiar with basic computer science, algorithms and data-structures, the problem solving questions are from that domain.
Rep
RepGayle L McDowell, CEO at CareerCup
Gayle Laakmann McDowell is the founder / CEO of CareerCup, which provides programming interview prep for candidates interviewing with Microsoft, Google ...
Rep
@still_code: You consider the "inner" cube of side (n-2). Now subtract the inner cubes from the total to give you the number of 1x1x1 cubes on the surface.
- Loler March 03, 2013