随笔分类 - Algorithm
摘要:Given an Array, find the number of inversion couples in the Arraye.g. 2, 4, 3, 1 4 -> (2,1), (3,1), (4,1), (4,3)hint:Solution 1* Iterate the whole a...
阅读全文
摘要:Given an ArrayList and a function " boolean test(someObject obj) "Test every element in the array list, delete all element that returns Fwith minimum ...
阅读全文
摘要:各种 Sort 算法,包括 Quick Sort, Merge Sort, Heap Sort, Count Sort 1 package Sort; 2 3 public class Sort { 4 /* 5 * Quick Sort 6 * Tim...
阅读全文
摘要:The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two leaves in the tree.The diameter of a tree T...
阅读全文
摘要:Let us consider the following 2 problems to understand Segment Tree.Problem 1 - Sum of Given RangeWe have an array arr[0 . . . n-1]. We should be able...
阅读全文
摘要:转载出处 http://www.cnblogs.com/AnnieKim/archive/2013/06/15/MorrisTraversal.html博主很认真,这里转载一下以防丢失链接本文主要解决一个问题,如何实现二叉树的前中后序遍历,有两个要求:1. O(1)空间复杂度,即只能使用常数空间;2...
阅读全文
摘要:No.1Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.e.g.[−2,1,−3,4,−1,2,1,−5,4...
阅读全文
摘要:文章 String S, 要查找的字符串 String W 重点:Get int T[] from W 用变量 c 来表示当前比较到的 W 中前面的字符,i 表示当前要处理的 T 中的 index,int[] T = new int[W.length];T[0] = -1; T[1] = 0;c=0
阅读全文
摘要:最近被各种 encode 和 decode 算法虐得很晕,总结一下,但愿有通解😫No.1Compress a string to remove duplicates when a character occurs +2 times continuously.e.g.input : "12 abbb...
阅读全文
摘要:You are given a grid of numbers. A snake sequence is made up of adjacent numbers such that for each number, the number on the right or the number belo...
阅读全文

浙公网安备 33010602011771号