Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

dynamic fib


private static Map<Integer, Integer> map = new HashMap<>();
public static void main(String[] argh){
 	
}

public static dynamicFib(int n){
	if(map.contain(n))
      return map.get(n);
 	if(n == 0) return 0;
  	if(n == 1) return 1;
  	
  	int ans = dynamicFib(n-1) + dynamicFiv(n-2);
  	map.put(n, ans);
  	return ans;
  	
}


 
PREVIOUS NEXT
Tagged: #dynamic #fib
ADD COMMENT
Topic
Name
9+5 =