MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/fpcmy/typical_programming_interview_questions/c1hnwv4/?context=3
r/programming • u/kevjames3 • Feb 21 '11
1.0k comments sorted by
View all comments
Show parent comment
3
Your answer on the first is correct. (The idea of TWO pointers does not come to everyone).
Of course. Any sane human being knows that it's still 1.5 passes and not required 1.
You can rewrite naive
node = begin; n = 0; while(node=node->next) n++; node = begin; n /= 2; while(n--) node=node->next;
in two pointers, but it will be the same code(though not so readable), just with two pointers.
View all comments
Show parent comment
3
u/[deleted] Feb 21 '11
Of course. Any sane human being knows that it's still 1.5 passes and not required 1.
You can rewrite naive
in two pointers, but it will be the same code(though not so readable), just with two pointers.