原文链接: https://leetcode-cn.com/problems/smallest-integer-divisible-by-k 英文原文Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1. Return the length of…
标签详情
数学 分类
原文链接: https://leetcode-cn.com/problems/convert-to-base-2 英文原文Given an integer n, return a binary string representing its representation in base -2. Note that the returned string should not have leading zeros unless the string is "0". Example 1: Input…
原文链接: https://leetcode-cn.com/problems/divisor-game 英文原文Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number n on the chalkboard. On each player's turn, that player makes a move consisting of: Choosing any …
原文链接: https://leetcode-cn.com/problems/matrix-cells-in-distance-order 英文原文You are given four integers row, cols, rCenter, and cCenter. There is a rows x cols matrix and you are on the cell with the coordinates (rCenter, cCenter). Return the coordinat…
原文链接: https://leetcode-cn.com/problems/moving-stones-until-consecutive 英文原文There are three stones in different positions on the X-axis. You are given three integers a, b, and c, the positions of the stones. In one move, you pick up a stone at an endp…
原文链接: https://leetcode-cn.com/problems/moving-stones-until-consecutive-ii 英文原文There are some stones in different positions on the X-axis. You are given an integer array stones, the positions of the stones. Call a stone an endpoint stone if it has the…
原文链接: https://leetcode-cn.com/problems/robot-bounded-in-circle 英文原文On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions: "G": go straight 1 unit; "L": turn 90 degrees to the left; "…
原文链接: https://leetcode-cn.com/problems/greatest-common-divisor-of-strings 英文原文For two strings s and t, we say "t divides s" if and only if s = t + ... + t (t concatenated with itself 1 or more times) Given two strings str1 and str2, return the larges…
原文链接: https://leetcode-cn.com/problems/statistics-from-a-large-sample 英文原文You are given a large sample of integers in the range [0, 255]. Since the sample is so large, it is represented by an array count where count[k] is the number of times that k a…
原文链接: https://leetcode-cn.com/problems/path-in-zigzag-labelled-binary-tree 英文原文In an infinite binary tree where every node has two children, the nodes are labelled in row order. In the odd numbered rows (ie., the first, third, fifth,...), the labelli…
原文链接: https://leetcode-cn.com/problems/distribute-candies-to-people 英文原文We distribute some number of candies, to a row of n = num_people people in the following way: We then give 1 candy to the first person, 2 candies to the second person, and so on …
原文链接: https://leetcode-cn.com/problems/graph-connectivity-with-threshold 英文原文We have n cities labeled from 1 to n. Two different cities with labels x and y are directly connected by a bidirectional road if and only if x and y share a common divisor s…
原文链接: https://leetcode-cn.com/problems/maximum-of-absolute-value-expression 英文原文Given two arrays of integers with equal lengths, return the maximum value of: |arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j| where the maximum is taken over all 0 <=…
原文链接: https://leetcode-cn.com/problems/n-th-tribonacci-number 英文原文The Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. Given n, return the value of Tn. Example 1: Input: n = 4 Output: 4 Exp…
原文链接: https://leetcode-cn.com/problems/stone-game-ii 英文原文Alice and Bob continue their games with piles of stones. There are a number of piles arranged in a row, and each pile has a positive integer number of stones piles[i]. The objective of the game…
原文链接: https://leetcode-cn.com/problems/reverse-subarray-to-maximize-array-value 英文原文You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1. You are allowed to sel…
原文链接: https://leetcode-cn.com/problems/day-of-the-year 英文原文Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year. Example 1: Input: date = "2019-01-09" Output: 9 Explanation: Given date …
原文链接: https://leetcode-cn.com/problems/number-of-days-between-two-dates 英文原文Write a program to count the number of days between two dates. The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples. Example 1: Input: date…
原文链接: https://leetcode-cn.com/problems/closest-divisors 英文原文Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2. Return the two integers in any order. Example 1: Input: num = 8 Output: [3…
原文链接: https://leetcode-cn.com/problems/prime-arrangements 英文原文Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.) (Recall that an integer is prime if and only if it is greater than 1, and cannot be writ…
原文链接: https://leetcode-cn.com/problems/four-divisors 英文原文Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0. Example 1: Input: nums…
原文链接: https://leetcode-cn.com/problems/day-of-the-week 英文原文Given a date, return the corresponding day of the week for that date. The input is given as three integers representing the day, month and year respectively. Return the answer as one of the f…
原文链接: https://leetcode-cn.com/problems/minimum-garden-perimeter-to-collect-enough-apples 英文原文In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate. The apple tree planted at an integer coordinate (…
原文链接: https://leetcode-cn.com/problems/ugly-number-iii 英文原文An ugly number is a positive integer that is divisible by a, b, or c. Given four integers n, a, b, and c, return the nth ugly number. Example 1: Input: n = 3, a = 2, b = 3, c = 5 Output: 4 Ex…
原文链接: https://leetcode-cn.com/problems/count-ways-to-build-rooms-in-an-ant-colony 英文原文You are an ant tasked with adding n new rooms numbered 0 to n-1 to your colony. You are given the expansion plan as a 0-indexed integer array of length n, prevRoom,…
原文链接: https://leetcode-cn.com/problems/sum-of-floored-pairs 英文原文Given an integer array nums, return the sum of floor(nums[i] / nums[j]) for all pairs of indices 0 <= i, j < nums.length in the array. Since the answer may be too large, return it modulo…
原文链接: https://leetcode-cn.com/problems/minimum-cost-to-move-chips-to-the-same-position 英文原文We have n chips, where the position of the ith chip is position[i]. We need to move all the chips to the same position. In one step, we can change the position…
原文链接: https://leetcode-cn.com/problems/find-positive-integer-solution-for-a-given-equation 英文原文Given a callable function f(x, y) with a hidden formula and a value z, reverse engineer the formula and return all positive integer pairs x and y where f(x…
原文链接: https://leetcode-cn.com/problems/circular-permutation-in-binary-representation 英文原文Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in the…
原文链接: https://leetcode-cn.com/problems/airplane-seat-assignment-probability 英文原文n passengers board an airplane with exactly n seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of passengers will: Take …