<commit_before>package com.sunny.grokkingalgorithms.fasttrack.dynamicprogrammingandrecursion;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by sundas on 6/12/2018.
 */
public class FibonacciNumbers {

   /*
   Fibonacci series
    */

  static Map<Integer,Long> memoizationCache = new HashMap<>();

  public static long fibonacciUsingMemoization(int n){
    if(n == 1 || n <= 0){
      return 1;
    }
    if(memoizationCache.containsKey(n)){
      return memoizationCache.get(n);
    }
    long fibN = fibonacciUsingMemoization(n - 1) + fibonacciUsingMemoization(n - 2);
    memoizationCache.put(n,fibN);
    return fibN;
  }

  /**
   *
   * @param n
   */
  public static int fibonacci(int n){
    if(n <= 0 || n == 1){<commit_msg>Correcting memoization logic.<commit_after>package com.sunny.grokkingalgorithms.fasttrack.dynamicprogrammingandrecursion;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by sundas on 6/12/2018.
 */
public class FibonacciNumbers {

   /*
   Fibonacci series
    */

  static Map<Integer,Long> memoizationCache = new HashMap<>();

  public static long fibonacciUsingMemoization(int n){
    if(n == 1 || n <= 0){
      memoizationCache.put(1,1L);
      memoizationCache.put(0,1L);
      return 1;
    }
    if(memoizationCache.containsKey(n)){
      return memoizationCache.get(n);
    }
    long fibN = fibonacciUsingMemoization(n - 1) + fibonacciUsingMemoization(n - 2);
    memoizationCache.put(n,fibN);
    return fibN;
  }

  /**
   *
   * @param n
   */
  public static int fibonacci(int n){
    if(n <= 0 || n == 1){
{'fraction_non_alphanumeric': 0.13018867924528302, 'fraction_numerical': 0.02012578616352201, 'mean_word_length': 3.1649214659685865, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1571768', 'n_tokens_mistral': 590, 'n_tokens_neox': 552, 'n_words': 113}