原文链接: https://leetcode-cn.com/problems/toeplitz-matrix 英文原文Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements. Example 1: I…
分类详情
简单 分类
原文链接: https://leetcode-cn.com/problems/search-in-a-binary-search-tree 英文原文You are given the root of a binary search tree (BST) and an integer val. Find the node in the BST that the node's value equals val and return the subtree rooted with that node.…
原文链接: https://leetcode-cn.com/problems/jewels-and-stones 英文原文You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to …
原文链接: https://leetcode-cn.com/problems/kth-largest-element-in-a-stream 英文原文Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Implement KthLargest cla…
原文链接: https://leetcode-cn.com/problems/binary-search 英文原文Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return …
原文链接: https://leetcode-cn.com/problems/minimum-distance-between-bst-nodes 英文原文Given the root of a Binary Search Tree (BST), return the minimum difference between the values of any two different nodes in the tree. Example 1: Input: root = [4,2,6,1,3] …
原文链接: https://leetcode-cn.com/problems/rotate-string 英文原文Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. A shift on s consists of moving the leftmost character of s to the rightmost positio…
原文链接: https://leetcode-cn.com/problems/design-hashset 英文原文Design a HashSet without using any built-in hash table libraries. Implement MyHashSet class: void add(key) Inserts the value key into the HashSet. bool contains(key) Returns whether the value …
原文链接: https://leetcode-cn.com/problems/design-hashmap 英文原文Design a HashMap without using any built-in hash table libraries. Implement the MyHashMap class: MyHashMap() initializes the object with an empty map. void put(int key, int value) inserts a (k…
原文链接: https://leetcode-cn.com/problems/unique-morse-code-words 英文原文International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: 'a' maps to ".-", 'b' maps to "-...", 'c' maps to "-.-.", …
原文链接: https://leetcode-cn.com/problems/number-of-lines-to-write-string 英文原文You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically, widths[0] is the width …
原文链接: https://leetcode-cn.com/problems/most-common-word 英文原文Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned. It is guaranteed there is at least one word that is not banned, and …
原文链接: https://leetcode-cn.com/problems/shortest-distance-to-a-character 英文原文Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the clos…
原文链接: https://leetcode-cn.com/problems/goat-latin 英文原文You are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to convert the sentence to "Goat Latin" (a made…
原文链接: https://leetcode-cn.com/problems/positions-of-large-groups 英文原文In a string s of lowercase letters, these letters form consecutive groups of the same character. For example, a string like s = "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z", a…
原文链接: https://leetcode-cn.com/problems/flipping-an-image 英文原文Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed. …
原文链接: https://leetcode-cn.com/problems/rectangle-overlap 英文原文An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its …
原文链接: https://leetcode-cn.com/problems/backspace-string-compare 英文原文Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after backspacing an empty text, the …
原文链接: https://leetcode-cn.com/problems/peak-index-in-a-mountain-array 英文原文Let's call an array arr a mountain if the following properties hold: arr.length >= 3 There exists some i with 0 < i < arr.length - 1 such that: arr[0] < arr[1] < ... arr[i-1] <…
原文链接: https://leetcode-cn.com/problems/buddy-strings 英文原文Given two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false. Swapping letters is defined as taking two indices i and j (0-…
原文链接: https://leetcode-cn.com/problems/lemonade-change 英文原文At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills). Each customer will only buy one lemo…
原文链接: https://leetcode-cn.com/problems/transpose-matrix 英文原文Given a 2D integer array matrix, return the transpose of matrix. The transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices. Exampl…
原文链接: https://leetcode-cn.com/problems/binary-gap 英文原文Given a positive integer n, find and return the longest distance between any two adjacent 1's in the binary representation of n. If there are no two adjacent 1's, return 0. Two 1's are adjacent if…
原文链接: https://leetcode-cn.com/problems/leaf-similar-trees 英文原文Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence. For example, in the given tree above, the leaf value sequence is …
原文链接: https://leetcode-cn.com/problems/middle-of-the-linked-list 英文原文Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. Example 1: Input: head = [1,2,3,4,5]…
原文链接: https://leetcode-cn.com/problems/projection-area-of-3d-shapes 英文原文You are given an n x n grid where we place some 1 x 1 x 1 cubes that are axis-aligned with the x, y, and z axes. Each value v = grid[i][j] represents a tower of v cubes placed on…
原文链接: https://leetcode-cn.com/problems/uncommon-words-from-two-sentences 英文原文A sentence is a string of single-space separated words where each word consists only of lowercase letters. A word is uncommon if it appears exactly once in one of the senten…
原文链接: https://leetcode-cn.com/problems/fair-candy-swap 英文原文Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the ith box of candy that Alic…
原文链接: https://leetcode-cn.com/problems/surface-area-of-3d-shapes 英文原文You are given an n x n grid where you have placed some 1 x 1 x 1 cubes. Each value v = grid[i][j] represents a tower of v cubes placed on top of cell (i, j). After placing these cub…
原文链接: https://leetcode-cn.com/problems/increasing-order-search-tree 英文原文Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and onl…