原文链接: https://leetcode-cn.com/problems/number-of-segments-in-a-string 英文原文You are given a string s, return the number of segments in the string. A segment is defined to be a contiguous sequence of non-space characters. Example 1: Input: s = "Hello, m…
分类详情
简单 分类
原文链接: https://leetcode-cn.com/problems/find-all-numbers-disappeared-in-an-array 英文原文Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums. Example 1:…
原文链接: https://leetcode-cn.com/problems/minimum-moves-to-equal-array-elements 英文原文Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal. In one move, you can increment n - 1 elements of the…
原文链接: https://leetcode-cn.com/problems/assign-cookies 英文原文Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor g[i], which is the minimum siz…
原文链接: https://leetcode-cn.com/problems/repeated-substring-pattern 英文原文Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. Example 1: Input: s = "abab" Output: true Expl…
原文链接: https://leetcode-cn.com/problems/hamming-distance 英文原文The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, return the Hamming distance between them. Exam…
原文链接: https://leetcode-cn.com/problems/number-complement 英文原文The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. For example, The integer 5 is "101" in binary and i…
原文链接: https://leetcode-cn.com/problems/license-key-formatting 英文原文You are given a license key represented as a string s that consists of only alphanumeric characters and dashes. The string is separated into n + 1 groups by n dashes. You are also give…
原文链接: https://leetcode-cn.com/problems/max-consecutive-ones 英文原文Given a binary array nums, return the maximum number of consecutive 1's in the array. Example 1: Input: nums = [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three…
原文链接: https://leetcode-cn.com/problems/construct-the-rectangle 英文原文A web developer needs to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose lengt…
原文链接: https://leetcode-cn.com/problems/teemo-attacking 英文原文Our hero Teemo is attacking an enemy Ashe with poison attacks! When Teemo attacks Ashe, Ashe gets poisoned for a exactly duration seconds. More formally, an attack at second t will mean Ashe …
原文链接: https://leetcode-cn.com/problems/next-greater-element-i 英文原文The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two distinct 0-indexed integer arrays num…
原文链接: https://leetcode-cn.com/problems/keyboard-row 英文原文Given an array of strings words, return the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below. In the American keyboard: the first r…
原文链接: https://leetcode-cn.com/problems/find-mode-in-binary-search-tree 英文原文Given the root of a binary search tree (BST) with duplicates, return all the mode(s) (i.e., the most frequently occurred element) in it. If the tree has more than one mode, re…
原文链接: https://leetcode-cn.com/problems/base-7 英文原文Given an integer num, return a string of its base 7 representation. Example 1: Input: num = 100 Output: "202" Example 2: Input: num = -7 Output: "-10" Constraints: -107 <= num <= 107 中文题目给定一个整数 num,将其…
原文链接: https://leetcode-cn.com/problems/relative-ranks 英文原文You are given an integer array score of size n, where score[i] is the score of the ith athlete in a competition. All the scores are guaranteed to be unique. The athletes are placed based on th…
原文链接: https://leetcode-cn.com/problems/perfect-number 英文原文A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. A divisor of an integer x is an integer that can divide x evenly. Given a…
原文链接: https://leetcode-cn.com/problems/detect-capital 英文原文We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All letters in this word are not capitals, like …
原文链接: https://leetcode-cn.com/problems/minimum-absolute-difference-in-bst 英文原文Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any two different nodes in the tree. Example 1: Input: root = [4,…
原文链接: https://leetcode-cn.com/problems/reverse-string-ii 英文原文Given a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string. If there are fewer than k characters left, reverse all of th…
原文链接: https://leetcode-cn.com/problems/diameter-of-binary-tree 英文原文Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This p…
原文链接: https://leetcode-cn.com/problems/student-attendance-record-i 英文原文You are given a string s representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day. The record on…
原文链接: https://leetcode-cn.com/problems/reverse-words-in-a-string-iii 英文原文Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: s = "Let's take Leet…
原文链接: https://leetcode-cn.com/problems/array-partition-i 英文原文Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized…
原文链接: https://leetcode-cn.com/problems/binary-tree-tilt 英文原文Given the root of a binary tree, return the sum of every tree node's tilt. The tilt of a tree node is the absolute difference between the sum of all left subtree node values and all right su…
原文链接: https://leetcode-cn.com/problems/reshape-the-matrix 英文原文In MATLAB, there is a handy function called reshape which can reshape an m x n matrix into a new one with a different size r x c keeping its original data. You are given an m x n matrix ma…
原文链接: https://leetcode-cn.com/problems/subtree-of-another-tree 英文原文Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise. A subtree of a …
原文链接: https://leetcode-cn.com/problems/distribute-candies 英文原文Alice has n candies, where the ith candy is of type candyType[i]. Alice noticed that she started to gain weight, so she visited a doctor. The doctor advised Alice to only eat n / 2 of the …
原文链接: https://leetcode-cn.com/problems/longest-harmonious-subsequence 英文原文We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1. Given an integer array nums, return the length of it…
原文链接: https://leetcode-cn.com/problems/big-countries 英文原文Table: World +-------------+---------+ | Column Name | Type | +-------------+---------+ | name | varchar | | continent | varchar | | area | int | | population | int | | gdp | int | +-----------…