mitshubh
BAN USER
Comments (4)
Reputation 10
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Since, the linked lists can be very large, we obviously cannot convert them into a number and subtract using a unary minus. So the trick to solve this question is to traverse the list and subtract the value of list1 with the value of list2 and also subtract the borrow. If the result is negative, add 10 to the final result.
- mitshubh October 26, 2013Comment hidden because of low score. Click to expand.
0
of 0 vote
This is an interesting one. A simple array can solve this problem. Loop 52 times (for all the card nos.) and swap each card (arr[i] with any random number i.e. arr[random] where you have chosen a random number from (i,51). This will give you a perfectly shuffled deck and that too in O(n) time:)
- mitshubh October 26, 2013Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
use a stack to keep track of the last node. Not move down (to the left/right) and check if the colors of the current node's left and right children AND the color of the node int the TOP of the stack are different. Call the function recursively, incrementing the value if you find a clump.
- mitshubh October 26, 2013