509. Fibonacci Number
2024年6月27日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 one […]
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 one […]
Use C to present Cup and \(C_{i,j}\) to present the fullness of the cup. Law of Shape: \(C_{i,j}\) exists if i>=0, 0<j<=i. Use \(I_{i,j}\) to pr […]
错误解法 Let nums = x_i. Change all \(x_i\) to y, find the minimum value of \(\Sigma |x_i-y|\), where y is palindromic, y > 0. Rather than finding \(\Sigm […]
第{{index + 2}}步,对于arr[{{index}}],即{{elenemt}},在cArr里进行标记。 cArr= 如果有以{{elenemt}}为后件的逆序对,那么该逆序对的前件一定在cArr索引{{elenemt+1}}到9(左闭右闭)区间内(以下划线表示)。这一步非常重要,请务必多 […]
LeetCode是用C# release模式运行的。 解法1: 使用队列进行广度优先搜索,统一在Dequeue后进行终止条件判断。 缺点是生成下一个状态,enqueue前,没有检查是不是解。 using System; using System.Collections.Generic; using […]
来自https://leetcode.com/problems/burst-balloons/ 题目 Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by […]
推导 给定下列列表(4指回2),若有快慢两个指针,慢指针每次前进一步,快指针每次前进两步,求两指针何处相遇? 1-2-3-4 |___| 解: 设两指针前进n次。n必定大于等于1。 [MathematicaIn n=”1″/]Reduce[Mod[n – 1, 3 […]
题目来自https://oj.leetcode.com/problems/fraction-to-recurring-decimal/。 Given two integers representing the numerator and denominator of a fraction, retu […]
题目来自https://oj.leetcode.com/problems/majority-element/。 分析部分摘抄自《线性时间查找固定频率的元素》,有改写。 题目 Given an array of size n, find the majority element. The majori […]
来自https://oj.leetcode.com/problems/maximum-gap/。 题目 Given an unsorted array, find the maximum difference between the successive elements in its sorted […]