原文链接: https://leetcode-cn.com/problems/delete-node-in-a-linked-list 英文原文Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted direct…
分类详情
简单 分类
原文链接: https://leetcode-cn.com/problems/valid-anagram 英文原文Given two strings s and t, return true if t is an anagram of s, and false otherwise. Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 2: Input: s = "rat", t = "car" Output: f…
原文链接: https://leetcode-cn.com/problems/binary-tree-paths 英文原文Given the root of a binary tree, return all root-to-leaf paths in any order. A leaf is a node with no children. Example 1: Input: root = [1,2,3,null,5] Output: ["1->2->5","1->3"] Example 2:…
原文链接: https://leetcode-cn.com/problems/ugly-number 英文原文An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return true if n is an ugly number. Example 1: Input: n = 6 Output: true Explanation: 6 = …
原文链接: https://leetcode-cn.com/problems/missing-number 英文原文Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: Input: nums = [3,0,1] Output: 2 Explanatio…
原文链接: https://leetcode-cn.com/problems/first-bad-version 英文原文You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed b…
原文链接: https://leetcode-cn.com/problems/move-zeroes 英文原文Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a copy of the array. E…
原文链接: https://leetcode-cn.com/problems/word-pattern 英文原文Given a pattern and a string s, find if s follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s. Example …
原文链接: https://leetcode-cn.com/problems/nim-game 英文原文You are playing the following Nim Game with your friend: Initially, there is a heap of stones on the table. You and your friend will alternate taking turns, and you go first. On each turn, the perso…
原文链接: https://leetcode-cn.com/problems/range-sum-query-immutable 英文原文Given an integer array nums, handle multiple queries of the following type: Calculate the sum of the elements of nums between indices left and right inclusive where left <= right. I…
原文链接: https://leetcode-cn.com/problems/power-of-three 英文原文Given an integer n, return true if it is a power of three. Otherwise, return false. An integer n is a power of three, if there exists an integer x such that n == 3x. Example 1: Input: n = 27 O…
原文链接: https://leetcode-cn.com/problems/counting-bits 英文原文Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i. Example 1: Input: n = 2 Output: [0,1,1…
原文链接: https://leetcode-cn.com/problems/power-of-four 英文原文Given an integer n, return true if it is a power of four. Otherwise, return false. An integer n is a power of four, if there exists an integer x such that n == 4x. Example 1: Input: n = 16 Outp…
原文链接: https://leetcode-cn.com/problems/reverse-string 英文原文Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory. Example 1: Input:…
原文链接: https://leetcode-cn.com/problems/reverse-vowels-of-a-string 英文原文Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases. Example 1: Input: s = "hel…
原文链接: https://leetcode-cn.com/problems/intersection-of-two-arrays 英文原文Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order. Example 1: In…
原文链接: https://leetcode-cn.com/problems/intersection-of-two-arrays-ii 英文原文Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you may retu…
原文链接: https://leetcode-cn.com/problems/valid-perfect-square 英文原文Given a positive integer num, write a function which returns True if num is a perfect square else False. Follow up: Do not use any built-in library function such as sqrt. Example 1: Inpu…
原文链接: https://leetcode-cn.com/problems/guess-number-higher-or-lower 英文原文We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I will tell you whether t…
原文链接: https://leetcode-cn.com/problems/ransom-note 英文原文Given two stings ransomNote and magazine, return true if ransomNote can be constructed from magazine and false otherwise. Each letter in magazine can only be used once in ransomNote. Example 1: I…
原文链接: https://leetcode-cn.com/problems/first-unique-character-in-a-string 英文原文Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: Input: s = "leetcode" Output: 0 Example 2: …
原文链接: https://leetcode-cn.com/problems/find-the-difference 英文原文You are given two strings s and t. String t is generated by random shuffling string s and then add one more letter at a random position. Return the letter that was added to t. Example 1: …
原文链接: https://leetcode-cn.com/problems/is-subsequence 英文原文Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can b…
原文链接: https://leetcode-cn.com/problems/convert-a-number-to-hexadecimal 英文原文Given an integer num, return a string representing its hexadecimal representation. For negative integers, two’s complement method is used. All the letters in the answer …
原文链接: https://leetcode-cn.com/problems/sum-of-left-leaves 英文原文Given the root of a binary tree, return the sum of all left leaves. Example 1: Input: root = [3,9,20,null,null,15,7] Output: 24 Explanation: There are two left leaves in the binary tree, w…
原文链接: https://leetcode-cn.com/problems/longest-palindrome 英文原文Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. Letters are case sensitive, for example…
原文链接: https://leetcode-cn.com/problems/binary-watch 英文原文A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least significant bi…
原文链接: https://leetcode-cn.com/problems/fizz-buzz 英文原文Given an integer n, return a string array answer (1-indexed) where: answer[i] == "FizzBuzz" if i is divisible by 3 and 5. answer[i] == "Fizz" if i is divisible by 3. answer[i] == "Buzz" if i is div…
原文链接: https://leetcode-cn.com/problems/third-maximum-number 英文原文Given an integer array nums, return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum number. Example 1: Input: nums = [3,2,1] Outp…
原文链接: https://leetcode-cn.com/problems/add-strings 英文原文Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the problem without using any built-in library for handling large…