## Count Primes

Given an integer n, return the number of prime numbers that are strictly less than n. https://leetcode.com/problems/count-primes/ Solution Code python class Solution: def countPrimes(self, n: int) -> int: if n <= 1: return 0 tmp = [True] * n for i in range(2, n): if(tmp[i]): for j in range(i*i, n, ......

## Factorial Trailing Zeroes

Given an integer n, return the number of trailing zeroes in n!. Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1. https://leetcode.com/problems/factorial-trailing-zeroes/ Solution Count How many 5 in the n Code python class Solution: def trailingZeroes(self, n: int) -> int: ret = 0 while n >= 5: n //= 5 ret += n return ret

## 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. https://leetcode.com/problems/missing-number/ code python class Solution: def missingNumber(self, nums: List[int]) -> int: # 应该的总和 - 实际的总和 return (len(nums) * (len(nums) + 1)) // 2 - sum(nums) # 利用......

## Coin Change | Dynamic Programming

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. You may assume that you have an infinite number of each kind of coin. https://leetco......

## Fibonacci Number | DpTable | Violent Hacking

The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. https://leetcode.com/problems/fibonacci-number/ Solution Violent Hacking / DP Table Code Violent Hacking O(2^n) submit code class Solution: def fib(self, n: int) -> int: ......

## 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. https://leetcode.com/problems/move-zeroes/ Solution Double Pointer / Fast And Slow Pointer Same with https://www.emperinter.info/2022/03/15/remove-duplicates-from-sorted-list/ we need......

## Remove Element

Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The relative order of the elements may be changed. Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k elements after removing the duplicates, then the fir...... 