Array 相关算法
与其对所有可能性的变化进行预测,不如做一个允许变化的计划
- 反转/部分反转 - code
- 左右旋转 - code
- 位置还原 - code
- 123456ABCDEF => 1A2B3C4D5E6F 转换 - newsmth.net/A Simple In-Place Algorithm for In-Shuffle/code
- 负数在前且相对位置不变 ex: { 1, 2, 3, -1, -2, -3, 4, -5 } => { -1, -2, -3, -5, 1, 2, 3, 4 } - newsmth.net/code
- 计算数组深度 - from @吴鑫 / code
- 拍平嵌套数组 - flat/code
- 最长连续子序列 (附带合并区间) - newsmth.net
- 删除重复元素 - from @张林
- 矩阵旋转
- 合并相交集合 - newsmth.net/code
- 二分查找 (附:出现在窗口的元素) - demo
- 二分变形 - newsmth.net/newsmth.net/newsmth.net/code
- 离元素最近的距离 - newsmth.net/code, maximize-distance-to-closest-person
- 单调性 - newsmth.net/code, newsmth.net/code
- 最长连续序列 - newsmth.net - code
- 相对顺序 - relative-sort-array /code
- 只有 { order: 1/2/3 } 时,排序 - newsmth.net/code
- 连续消除 - newsmth.net / code:ai
- 合并数组,但保持原数组内顺序,求所有可能合并后数列 - newsmth.net / code:ai
- 窗口内最大值 - code:api