摘要: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
阅读全文
摘要:Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the sa
阅读全文
摘要:Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). Example 1: Input: root = [1,2,2,3,4,4,3]
阅读全文
摘要:Given the roots of two binary trees p and q, write a function to check if they are the same or not. Two binary trees are considered the same if they a
阅读全文
摘要:You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list
阅读全文
摘要:Write a function that takes an unsigned integer and return the number of '1' bits it has (also known as the Hamming weight). Example 1: Example 2: Exa
阅读全文
摘要:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements
阅读全文
摘要:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen
阅读全文
摘要:Given a string containing only three types of characters: '(', ')' and ' ', write a function to check whether this string is valid. We define the vali
阅读全文
摘要:Given an array nums of n integers where n 1, return an array output such that output[i] is equal to the product of all the elements of nums except num
阅读全文