2.7 Implement a function to check if a linked list is a palindrome.回复解法可以按照以下格式来Notice:1、记得在程序注释中表明自己算法的时间、空间 ...
2.6Given a circular linked list, implement an algorithm which returns the node at the beginning of the loop.DEFINITIONCircular linked list: A (corrupt) li ...
2.5You 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 digit ...
2.4 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.回复解法可以按 ...
2.3Implement 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 ...
2.2 Implement an algorithm to find the kth to last element of a singly linked list.回复解法可以按照以下格式来Notice:1、记得在程序注释中表明自己算法 ...
2.1 Write code to remove duplicates from an unsorted linked list.FOLLOW UPHow would you solve this problem if a temporary buffer is not allowed?回复解 ...
4.1 Implement a function to check if a binary tree is balanced. For the purposes of this question, a balanced tree is defined to be a tree such that the heights ...
3.2 How would you design a stack which, in addition to push and pop, also has a function min which returns the minimum element? Push, pop and min should all ope ...
1.8 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 rotati ...
1.7 Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0.回复解法可以按照以下格式来Notice:1、 ...
3.1 Describe how you could use a single array to implement three stacks.回复解法可以按照以下格式来Notice:1、记得在程序注释中表明自己算法的时间、 ...
4.4 Given a binary tree, design an algorithm which creates a linked list of all the nodes at each depth (e.g., if you have a tree with depth D,you'll have D lin ...
4.3 Given a sorted (increasing order) array with unique integer elements, write an algorithm to create a binary search tree with minimal height.回复解法可以 ...
4.2 Given a directed graph, design an algorithm to find out whether there is a route between two nodes.回复解法可以按照以下格式来Notice:1、记得在程 ...
3.7 An animal shelter holds only dogs and cats, and operates on a strictly "first in, first out" basis. People must adopt either the "oldest" (based on arrival ...
3.6 Write a program to sort a stack in ascending order (with biggest items on top). You may use at most one additional stack to hold items, but you may not copy ...
3.5 Implement a MyQueue class which implements a queue using two stacks.回复解法可以按照以下格式来Notice:1、记得在程序注释中表明自己算法的时间、 ...
3.4 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 disks s ...
3.3 Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the previo ...