原文链接: https://leetcode-cn.com/problems/different-ways-to-add-parentheses 英文原文Given a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. You may return…
标签详情
数学 分类
原文链接: 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/ugly-number-ii 英文原文An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return the nth ugly number. Example 1: Input: n = 10 Output: 12 Explanation: [1, 2, 3, …
原文链接: 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/integer-to-english-words 英文原文Convert a non-negative integer num to its English words representation. Example 1: Input: num = 123 Output: "One Hundred Twenty Three" Example 2: Input: num = 12345 Output: "Twelve T…
原文链接: https://leetcode-cn.com/problems/perfect-squares 英文原文Given an integer n, return the least number of perfect square numbers that sum to n. A perfect square is an integer that is the square of an integer; in other words, it is the product of some…
原文链接: https://leetcode-cn.com/problems/expression-add-operators 英文原文Given a string num that contains only digits and an integer target, return all possibilities to insert the binary operators '+', '-', and/or '*' between the digits of num so that the…
原文链接: 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/bulb-switcher 英文原文There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turnin…
原文链接: 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/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/integer-break 英文原文Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers. Return the maximum product you can get. Example 1: Input: n = 2 Outpu…
原文链接: https://leetcode-cn.com/problems/water-and-jug-problem 英文原文You are given two jugs with capacities jug1Capacity and jug2Capacity liters. There is an infinite amount of water supply available. Determine whether it is possible to measure exactly t…
原文链接: 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/sum-of-two-integers 英文原文Given two integers a and b, return the sum of the two integers without using the operators + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: Input: a = 2, b = 3 Output: 5 Const…
原文链接: https://leetcode-cn.com/problems/super-pow 英文原文Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array. Example 1: Input: a = 2, b = [3] Output: 8 Example 2:…
原文链接: https://leetcode-cn.com/problems/guess-number-higher-or-lower-ii 英文原文We are playing the Guessing Game. The game will work as follows: I pick a number between 1 and n. You guess a number. If you guess the right number, you win the game. If you g…
原文链接: https://leetcode-cn.com/problems/insert-delete-getrandom-o1 英文原文Implement the RandomizedSet class: RandomizedSet() Initializes the RandomizedSet object. bool insert(int val) Inserts an item val into the set if not present. Returns true if the i…
原文链接: https://leetcode-cn.com/problems/insert-delete-getrandom-o1-duplicates-allowed 英文原文RandomizedCollection is a data structure that contains a collection of numbers, possibly duplicates (i.e., a multiset). It should support inserting and removing …
原文链接: https://leetcode-cn.com/problems/linked-list-random-node 英文原文Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen. Implement the Solution class: Solution(ListNod…
原文链接: https://leetcode-cn.com/problems/shuffle-an-array 英文原文Given an integer array nums, design an algorithm to randomly shuffle the array. All permutations of the array should be equally likely as a result of the shuffling. Implement the Solution cl…
原文链接: https://leetcode-cn.com/problems/rotate-function 英文原文You are given an integer array nums of length n. Assume arrk to be an array obtained by rotating nums by k positions clock-wise. We define the rotation function F on nums as follow: F(k) = 0 …
原文链接: https://leetcode-cn.com/problems/random-pick-index 英文原文Given an integer array nums with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array. Implement the …
原文链接: https://leetcode-cn.com/problems/nth-digit 英文原文Given an integer n, return the nth digit of the infinite integer sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]. Example 1: Input: n = 3 Output: 3 Example 2: Input: n = 11 Output: 0 Explanation:…
原文链接: 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/elimination-game 英文原文You have a list arr of all integers in the range [1, n] sorted in a strictly increasing order. Apply the following algorithm on arr: Starting from left to right, remove the first number and …
原文链接: 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/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…
原文链接: https://leetcode-cn.com/problems/reconstruct-original-digits-from-english 英文原文Given a string s containing an out-of-order English representation of digits 0-9, return the digits in ascending order. Example 1: Input: s = "owoztneoer" Output: "01…
原文链接: https://leetcode-cn.com/problems/add-two-numbers-ii 英文原文You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers…