LeetCode – Longest Increasing Path in a Matrix (Java)

Given an integer matrix, get the length of the longest increasing path. https://leetcode.com/problems/longest-increasing-path-in-a-matrix/ Java Solution 1 – Naive DFS public int longestIncreasingPath(int[][] matrix) { int[] max = new int[1]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[0].length; j++) { dfs(matrix, i, j, max, 1); } … Read more