原文链接: https://leetcode-cn.com/problems/two-sum 英文原文Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may n…
分类详情
简单 分类
原文链接: https://leetcode-cn.com/problems/reverse-integer 英文原文Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the en…
原文链接: https://leetcode-cn.com/problems/palindrome-number 英文原文Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not. Example 1…
原文链接: https://leetcode-cn.com/problems/roman-to-integer 英文原文Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just tw…
原文链接: https://leetcode-cn.com/problems/longest-common-prefix 英文原文Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: strs = ["flower","flow"…
原文链接: https://leetcode-cn.com/problems/valid-parentheses 英文原文Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the sam…
原文链接: https://leetcode-cn.com/problems/merge-two-sorted-lists 英文原文You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two li…
原文链接: https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array 英文原文Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the eleme…
原文链接: https://leetcode-cn.com/problems/implement-strstr 英文原文Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Clarification: What should we return when needle is an empty stri…
原文链接: https://leetcode-cn.com/problems/search-insert-position 英文原文Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must…
原文链接: https://leetcode-cn.com/problems/maximum-subarray 英文原文Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. Example …
原文链接: https://leetcode-cn.com/problems/length-of-last-word 英文原文Given a string s consisting of some words separated by some number of spaces, return the length of the last word in the string. A word is a maximal substring consisting of non-space chara…
原文链接: https://leetcode-cn.com/problems/plus-one 英文原文You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-…
原文链接: https://leetcode-cn.com/problems/add-binary 英文原文Given two binary strings a and b, return their sum as a binary string. Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" Constraints: 1 <= …
原文链接: https://leetcode-cn.com/problems/sqrtx 英文原文Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned. Note…
原文链接: https://leetcode-cn.com/problems/climbing-stairs 英文原文You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Input: n = 2 Outpu…
原文链接: https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list 英文原文Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. Example 1: Input: head = [1,1…
原文链接: https://leetcode-cn.com/problems/merge-sorted-array 英文原文You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1…
原文链接: https://leetcode-cn.com/problems/binary-tree-inorder-traversal 英文原文Given the root of a binary tree, return the inorder traversal of its nodes' values. Example 1: Input: root = [1,null,2,3] Output: [1,3,2] Example 2: Input: root = [] Output: [] …
原文链接: https://leetcode-cn.com/problems/same-tree 英文原文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 are structurally identical, and the nodes have t…
原文链接: https://leetcode-cn.com/problems/symmetric-tree 英文原文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] Output: true Example 2: Input: root = [1,2…
原文链接: https://leetcode-cn.com/problems/maximum-depth-of-binary-tree 英文原文Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest lea…
原文链接: https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree 英文原文Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. A height-balanced binary tree is a…
原文链接: https://leetcode-cn.com/problems/balanced-binary-tree 英文原文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 left and right subtrees of every node d…
原文链接: https://leetcode-cn.com/problems/minimum-depth-of-binary-tree 英文原文Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a …
原文链接: https://leetcode-cn.com/problems/path-sum 英文原文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 path equals targetSum. A leaf is a node with no…
原文链接: https://leetcode-cn.com/problems/pascals-triangle 英文原文Given an integer numRows, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: Example 1: Input: numRows…
原文链接: https://leetcode-cn.com/problems/pascals-triangle-ii 英文原文Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: Exam…
原文链接: https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock 英文原文You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choo…
原文链接: https://leetcode-cn.com/problems/valid-palindrome 英文原文A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric …
1 / 16