DataUtil { public static void pickNum(int[] originArray, int n, int m, int[] selectArray, int startIndex, boolean inorder) { if (originArray == null || originArray.length == 0 || n < 1) { return; } if (inorder) { if (originArray[startIndex] > m) { return; } if (m < 0 && originArray[originArray.length - 1] < m) { return; } } if (n == 1) { for (int i = startIndex; i < originArray.length; i++) { if (originArray[i] == m) { selectArray[selectArray.length - n] = originArray[i]; System.out.println("one of successful result is: "); for (int j = 0; j < selectArray.length; j++) { System.out.print(selectArray[j] + "\t"); } System.out.println("\n"); return; } } return; } for (int i = startIndex; i <= originArray.length - n; i++) { selectArray[selectArray.length - n] = originArray[i]; pickNum(originArray, n - 1, m - originArray[i], selectArray, i + 1, inorder); } }  static int getMatrixHeavy(int[][] matrix, int m, int n); static int maxSequenceSum(int[] array); static int fibonacciRecursive(int n); static int fibonacci(int n); static int findMaxUnContinuousSum(int[] array); static void findContinuousSequenceMethod1(int n); static void findContinuousSequenceMethod2(int n); static void findContinuousSequenceMethod3(int n); static void findContinuousSequenceMethod4(int n); static void pickNum(int[] originArray, int n, int m, int[] selectArray, int startIndex, boolean inorder); static int binarySearch(int[] array, int key); static int findFirstEqual(int[] array, int key); static int findFirstEqualLarger(int[] array, int key); static int findFirstLarger(int[] array, int key); static int findLastEqual(int[] array, int key); static int findLastEqualSmaller(int[] array, int key); static List<Integer> shufflePump(List<Integer> origin); static List<Integer> shuffleSwap(List<Integer> origin); static int[] shuffleSwap(int[] origin); static String getAccurateDivide(int a, int b, int n); static Set<Integer> getPrimeNumInefficient(int range); static Set<Integer> getPrimeNumEfficient(int range); static int getIntervalDays(int year, int month, int day); static int pageHelper(int n, int m); static boolean isOdd(int num);  }
@Test public void pickNum() { int n1 = 2; int m1 = 5; int[] originArray1 = {1, 2, 3, 4, 5, 6}; int[] selectArray1 = new int[n1]; DataUtil.pickNum(originArray1, n1, m1, selectArray1, 0, true); System.out.println("------"); int n2 = 3; int m2 = 10; int[] originArray2 = {1, 2, 3, 4, 5, 6}; int[] selectArray2 = new int[n2]; DataUtil.pickNum(originArray2, n2, m2, selectArray2, 0, true); System.out.println("------"); int n3 = 2; int m3 = -5; int[] originArray3 = {-6, -5, -4, -3, -2, -1}; int[] selectArray3 = new int[n3]; DataUtil.pickNum(originArray3, n3, m3, selectArray3, 0, true); System.out.println("------"); int n4 = 3; int m4 = 0; int[] originArray4 = {6, -3, -2, 1, 4, 2, 5, 3}; int[] selectArray4 = new int[n4]; DataUtil.pickNum(originArray4, n4, m4, selectArray4, 0, false); SortUtil.bubbleSort(originArray4); DataUtil.pickNum(originArray4, n4, m4, selectArray4, 0, true); }