分类: LeetCode

树状数组求逆序对

2019年10月3日

第{{index + 2}}步,对于arr[{{index}}],即{{elenemt}},在cArr里进行标记。 cArr= 如果有以{{elenemt}}为后件的逆序对,那么该逆序对的前件一定在cArr索引{{elenemt+1}}到9(左闭右闭)区间内(以下划线表示)。这一步非常重要,请务必多 […]

126. Word Ladder II

2019年8月29日

LeetCode是用C# release模式运行的。 解法1: 使用队列进行广度优先搜索,统一在Dequeue后进行终止条件判断。 缺点是生成下一个状态,enqueue前,没有检查是不是解。 using System; using System.Collections.Generic; using […]

Burst Balloons

2015年12月5日

来自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 […]

检查链表是否有环,带数学推导

2015年1月9日

推导 给定下列列表(4指回2),若有快慢两个指针,慢指针每次前进一步,快指针每次前进两步,求两指针何处相遇? 1-2-3-4 |___| 解: 设两指针前进n次。n必定大于等于1。 [MathematicaIn n=”1″/]Reduce[Mod[n – 1, 3 […]

Maximum Gap

2014年12月15日

来自https://oj.leetcode.com/problems/maximum-gap/。 题目 Given an unsorted array, find the maximum difference between the successive elements in its sorted […]