摘要:Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (F
阅读全文
摘要:mplement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, peek
阅读全文
摘要:Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top,
阅读全文
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: MinStack() initializes
阅读全文
摘要:Given the head of a singly linked list and two integers left and right where left ⇐ right, reverse the nodes of the list from position left to positio
阅读全文
摘要:Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head. Example
阅读全文
摘要:Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where the sum of the node values in the path equals targetSum.
阅读全文
摘要:Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the
阅读全文
摘要:Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: The left subtree of a node co
阅读全文
摘要:Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the lef
阅读全文
摘要:Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level). Example1: Input: r
阅读全文