Minimum Number of Days to Eat N Oranges LeetCode solution in Java
1class Solution {2HashMap<Integer, Integer> map;34public int minDays(int n) {5map = new HashMap<>();6map.put(0, 0);7map.put(1, 1);8return dp(n);9}1011public int dp(int n) {12if (map.get(n) != null) return map.get(n);13int one = 1 + (n % 2) + dp(n / 2);14int two = 1 + (n % 3) + dp(n / 3);15map.put(n, Math.min(one, two));16return map.get(n);17}18}19// int one = 1+(n%2)+cache(n/2);20// int two = 1+(n%3)+cache(n/3);