We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import java.util.HashMap; import java.util.Map;
class HelloWorld { private static Map<String, Integer> cache = new HashMap<>();
public static void main(String[] args) { int n = 5, i, j; for (i = 0; i < n; i++) { for (j = 0; j <= i; j++) { System.out.print(array(i, j) + " "); } System.out.println(); } } private static int array(int row, int col) { if (col==0||col==row) return 1; String key = row + "-" + col; if (cache.containsKey(key)) return cache.get(key); int result = array(row - 1, col - 1) + array(row - 1, col); cache.put(key, result); return result; }
}
No response
The text was updated successfully, but these errors were encountered:
Please create a pull request with a detailed description of the algorithm instead
Sorry, something went wrong.
No branches or pull requests
What would you like to share?
import java.util.HashMap;
import java.util.Map;
class HelloWorld {
private static Map<String, Integer> cache = new HashMap<>();
}
Additional information
No response
The text was updated successfully, but these errors were encountered: