java
Valars
壁立千仞,无欲则刚
展开
-
Java实现全排列
全排列是将一组数(非重复)按一定顺序进行排列,如果这组数有n个,那么全排列数为n!个。可以采用递归的方式实现。 public class Perm{ static numPerm=0; public static void main(String[] args){ Perm perm=new Perm(); String[]原创 2017-06-05 16:13:52 · 354 阅读 · 0 评论 -
求二叉排序树的最小公共根
[题目]给定一棵深度为K的二叉排序树, 求a和b(a >= b)的最小公共根. public class Solve { public static void main(String[] args) { int aa=minRoot(4, 10, 13); int bb=minRoot(4, aa, 15); System.out.println(bb); } ...原创 2017-04-04 07:39:09 · 2232 阅读 · 0 评论 -
逆序对(字符串,只包含ABCD字符)
[题目]字符串S中,只包含字符'A'/'B'/'C'/'D', 求字符串S中的逆序对. public class ReverseOrder { public static void main(String[] args { int aa = reverseNums("DBCBBA"); System.out.println(aa); } public static int ...原创 2017-04-04 07:58:44 · 1840 阅读 · 0 评论