摘要:
In the classic problem of the Towers of Hanoi, you have 3 towers and Ndisks of different sizes which can slide onto any tower.The puzzle starts with d... 阅读全文
摘要:
Describe how you could use a single array to implement three stacks.Divide the array into three fixed parts, each stands for a stack./*Fixed Size Stac... 阅读全文
摘要:
Implement a function to check if a linked list is a palindrome.Reverse the second half of the list and then compare it with the first half./* Assume t... 阅读全文
摘要:
Given a circular linked list, implement an algorithm which returns the node at the beginning of the loop.DEFINITIONCircular linked list: A (corrupt) l... 阅读全文
摘要:
You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the Ts d... 阅读全文
摘要:
Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x.Use two addit... 阅读全文
摘要:
Implement an algorithm to delete a node in the middle of a singly linked list, given only access to that node.EXAMPLEInput: the node c from the linked... 阅读全文
摘要:
Implement an algorithm to find the kth to last element of a singly linked list.Classical "Runner" Technique of linkedlist/*Use two pointers, forward o... 阅读全文
摘要:
Write code to remove duplicates from an unsorted linked list.FOLLOW UPHow would you solve this problem if a temporary buffer is not allowed?/* Use a H... 阅读全文
摘要:
Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a ... 阅读全文