1. 程式人生 > >Data Structure and Algorithm

Data Structure and Algorithm

spa ash stack brush truct ati clas static tro

Array & ArrayList

String

LinkedList

Stack & Queue

Recursion

1. Knapsack non-repeating items. Not Bug Free

  思路一:最直接的recursion.

public static boolean exist(int[] nums, int target, int index) {
    	 if (target == 0) {
	     return true;
	 }
	 if (index == nums.length || target < 0) {
	     return false;
	 }
	 return exist(nums, target - nums[index], index++) || exist(nums, target, index++);
    }

  

Tree & Graph

Binary Search

Sort

HashMap

Data Structure and Algorithm