原文链接: https://leetcode-cn.com/problems/single-number 英文原文Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant …
分类详情
简单 分类
原文链接: https://leetcode-cn.com/problems/linked-list-cycle 英文原文Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by conti…
原文链接: https://leetcode-cn.com/problems/binary-tree-preorder-traversal 英文原文Given the root of a binary tree, return the preorder traversal of its nodes' values. Example 1: Input: root = [1,null,2,3] Output: [1,2,3] Example 2: Input: root = [] Output: […
原文链接: https://leetcode-cn.com/problems/binary-tree-postorder-traversal 英文原文Given the root of a binary tree, return the postorder traversal of its nodes' values. Example 1: Input: root = [1,null,2,3] Output: [3,2,1] Example 2: Input: root = [] Output:…
原文链接: https://leetcode-cn.com/problems/min-stack 英文原文Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: MinStack() initializes the stack object. void push(int val) pushes th…
原文链接: https://leetcode-cn.com/problems/intersection-of-two-linked-lists 英文原文Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null…
原文链接: https://leetcode-cn.com/problems/two-sum-ii-input-array-is-sorted 英文原文Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two …
原文链接: https://leetcode-cn.com/problems/excel-sheet-column-title 英文原文Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... Example 1: I…
原文链接: https://leetcode-cn.com/problems/majority-element 英文原文Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element a…
原文链接: https://leetcode-cn.com/problems/excel-sheet-column-number 英文原文Given a string columnTitle that represents the column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> …
原文链接: https://leetcode-cn.com/problems/combine-two-tables 英文原文Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | personId | int | | lastName | varchar | | firstName | varchar | +-------------+---------+ personI…
原文链接: https://leetcode-cn.com/problems/duplicate-emails 英文原文Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | email | varchar | +-------------+---------+ id is the primary key column for this tabl…
原文链接: https://leetcode-cn.com/problems/customers-who-never-order 英文原文Table: Customers +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | name | varchar | +-------------+---------+ id is the primary key column fo…
原文链接: https://leetcode-cn.com/problems/reverse-bits 英文原文Reverse bits of a given 32 bits unsigned integer. Note: Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signe…
原文链接: https://leetcode-cn.com/problems/number-of-1-bits 英文原文Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). Note: Note that in some languages, such as Java, there is no uns…
原文链接: https://leetcode-cn.com/problems/valid-phone-numbers 英文原文Given a text file file.txt that contains a list of phone numbers (one per line), write a one-liner bash script to print all valid phone numbers. You may assume that a valid phone number m…
原文链接: https://leetcode-cn.com/problems/tenth-line 英文原文Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has the following content: Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 Line 9 Line 10 Yo…
原文链接: https://leetcode-cn.com/problems/delete-duplicate-emails 英文原文Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | email | varchar | +-------------+---------+ id is the primary key column for th…
原文链接: https://leetcode-cn.com/problems/rising-temperature 英文原文Table: Weather +---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | recordDate | date | | temperature | int | +---------------+---------+ id is the…
原文链接: https://leetcode-cn.com/problems/happy-number 英文原文Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squa…
原文链接: https://leetcode-cn.com/problems/isomorphic-strings 英文原文Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be repl…
原文链接: https://leetcode-cn.com/problems/reverse-linked-list 英文原文Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Example 2: Input: head = [1,2] Output: [2,…
原文链接: https://leetcode-cn.com/problems/contains-duplicate 英文原文Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Example 1: Input: nums = [1,2,3,1] Output: true Ex…
原文链接: https://leetcode-cn.com/problems/contains-duplicate-ii 英文原文Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k. Example 1: Input: nums…
原文链接: https://leetcode-cn.com/problems/invert-binary-tree 英文原文Given the root of a binary tree, invert the tree, and return its root. Example 1: Input: root = [4,2,7,1,3,6,9] Output: [4,7,2,9,6,3,1] Example 2: Input: root = [2,1,3] Output: [2,3,1] Exa…
原文链接: https://leetcode-cn.com/problems/summary-ranges 英文原文You are given a sorted unique integer array nums. Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of nums is covered by exactly…
原文链接: https://leetcode-cn.com/problems/power-of-two 英文原文Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2x. Example 1: Input: n = 1 Output: …
原文链接: https://leetcode-cn.com/problems/implement-queue-using-stacks 英文原文Implement 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, pop, and empty). Implemen…
原文链接: https://leetcode-cn.com/problems/palindrome-linked-list 英文原文Given the head of a singly linked list, return true if it is a palindrome. Example 1: Input: head = [1,2,2,1] Output: true Example 2: Input: head = [1,2] Output: false Constraints: The…
原文链接: https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-search-tree 英文原文Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “T…