Documentation
¶
Index ¶
- Variables
- func ClimbStairs(x int) int
- func FindDisappearedNumbers(nums []int) []int
- func GetRow(n int) []int
- func IToR(n int) (string, error)
- func IsHappyNum(n int) bool
- func IsUgly(n int) bool
- func IsValidSerialization(preorder string) bool
- func LongestOnes(A []int, K int) int
- func MaximumScore(a int, b int, c int) int
- func MaximumUnits(boxTypes [][]int, truckSize int) int
- func MyPow(x float64, n int) float64
- func PlusOne(digits []int) []int
- func ReinitializePermutation(n int) int
- func SearchInsert(nums []int, target int) int
- func SmallestRepunitDivByK(k int) int
- func SplitNum(num int) int
- func SqrtX(x int) int
- func SumIndicesWithKSetBits(nums []int, k int) int
- func ThreeSumClosest(nums []int, target int) int
- type IntPair
- type NumArray
Constants ¶
This section is empty.
Variables ¶
var ErrOutOfBound = errors.New("n must be less than 4000 and greater than 0")
ErrOutOfBound is a error that input number is not less than 4000 and greater than 0
Functions ¶
func ClimbStairs ¶
ClimbStairs returns there are how many distinct ways can you climb to the top. Each time you can either climb 1 or 2 steps. f(x) = f(x-1) + f(x-2)
func FindDisappearedNumbers ¶
FindDisappearedNumbers returns an array of all the integers in the range [1, n] that do not appear in nums.
func IsHappyNum ¶
IsHappyNum returns true if a number n is happy. A happy number defined by follow process:
Starting with any positive integer, replace the number by the sum of the squares of its digits. Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy.
func IsUgly ¶
IsUgly returns true if n is a ugly number. Ugly number is a positive number whose prime factors only include 2, 3, and/or 5
func IsValidSerialization ¶
IsValidSerialization returns true if it is a correct preorder traversal serialization of a binary tree.
func LongestOnes ¶
LongestOnes return the maximum number of consecutive 1's in the array if you can flip at most k 0's
origin:https://leetcode-cn.com/problems/max-consecutive-ones-iii
func MaximumScore ¶
MaximumScore returns step tha make a, b c be zero. Every step can minus two of a, b, c.
func MaximumUnits ¶
MaximumUnits returns the maximum number of boxes that can be put on the truck. The numberOfBoxes[i] is the number of boxes of type i. The numberOfUnitsPerBox[i] is the number of units in each box of the type i
func PlusOne ¶
PlusOne increments the large integer by one and return the resulting array of digits.
func ReinitializePermutation ¶
ReinitializePermutation returns the minimum non-zero number of operations you need to perform on perm to return the permutation to its initial value. Perm is a permutation perm of size n where perm[i] == i (0-indexed). In one operation, you will create a new array arr, and for each i: 1. If i % 2 == 0, then arr[i] = perm[i / 2] 2. If i % 2 == 1, then arr[i] = perm[n / 2 + (i - 1) / 2]
func SearchInsert ¶
SearchInsert return the index if the target is found. If not, return the index where it would be if it were inserted in order
func SmallestRepunitDivByK ¶
func SumIndicesWithKSetBits ¶
func ThreeSumClosest ¶
ThreeSsumClosest returns the closest sum of three integers in nums to target