![]() ![]() Design your implementation of the circular queue.īelow, we take a look at some more questions and provide you with links to high quality solutions to them.Evaluate the value of an arithmetic expression in Reverse Polish Notation.Given an integer array "nums" and an integer "k," return the length of the shortest non-empty subarray of "nums" with a sum of at least "k.".Given a string of round, curly, and square opening and closing brackets, return whether the brackets are balanced (well-formed).There are also two possible class implemntations of it, oneĪnd another one based on linked lists ( LinkedList).5 typical stacks and queues interview questions ![]() ![]() Aĭeque is defined by the following interface: Interfaceĭeque. However, in the Java API there areĪlso several classes that implement such data structures. In this exercise, we have practice with the design and ToString() method that permits to print the content of theĭeque on console according the next format (the shown This method returns the size of the DLL list. This method extracts an object from the end of theĭLL and removes it from the list. This method extracts an object from the beginning This method inserts an object at the end of the This method inserts an object at the beginnig of Program the Node class, the List class and the following methods of the List class: If currentPosition is pointing to null, nothing is extracted and null is returned. After the insertion, currentPosition must point to the new node inserted.Įxtracting data from the list: return the data pointed by currentPosition, delete the node, and moves currentPosition to the next node ( currentPosition will point to null if there is no next node). When currentPosition is null, the new node is inserted into the top of the list. the new node will follow the node currently referenced by currentPosition. Insert new data in the list: a new node is inserted to save this data, immediately following currentPosition, i.e. If it is required to move backwards more positions than number of nodes from the current position up until the first node of the list, the reference will remain in this first node. If the list is empty or the number of positions to move backwards is not greater than zero, nothing is done. Move the currentPosition reference backwards: the reference currentPosition must go backwards as many positions as indicated. If currentPosition points to null before proceeding, it is first placed pointing to the first node of the list, and then moved forwards the specified number of positions minus one (for example, if it is required to move 5 positions forwards and currentPosition points initially to null, then currentPosition is first placed pointing to the first node, and then moved 4 positions from this first one). If it is required to move it forwards more positions than number of nodes from the current position up until the end of the list, advance currentPosition only until the last node. ![]() If the list is empty or the number of positions to move forwards is not greater than zero, nothing is done. Move the reference position forwards: the reference is moving forwards as many positions as indicated. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |