{"id":22513660,"url":"https://github.com/emahtab/minimum-path-sum","last_synced_at":"2026-02-17T22:31:56.488Z","repository":{"id":79525665,"uuid":"272580340","full_name":"eMahtab/minimum-path-sum","owner":"eMahtab","description":"Minimum Path Sum","archived":false,"fork":false,"pushed_at":"2020-06-16T01:40:14.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-19T19:58:41.150Z","etag":null,"topics":["dynamic-programming","leetcode","problem-solving"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eMahtab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-06-16T01:23:56.000Z","updated_at":"2020-06-16T01:40:43.000Z","dependencies_parsed_at":"2023-05-10T17:30:37.473Z","dependency_job_id":null,"html_url":"https://github.com/eMahtab/minimum-path-sum","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eMahtab/minimum-path-sum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fminimum-path-sum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fminimum-path-sum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fminimum-path-sum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fminimum-path-sum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMahtab","download_url":"https://codeload.github.com/eMahtab/minimum-path-sum/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fminimum-path-sum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29560779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T21:50:49.831Z","status":"ssl_error","status_checked_at":"2026-02-17T21:46:15.313Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic-programming","leetcode","problem-solving"],"created_at":"2024-12-07T03:13:56.790Z","updated_at":"2026-02-17T22:31:56.477Z","avatar_url":"https://github.com/eMahtab.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minimum path sum\n## https://leetcode.com/problems/minimum-path-sum\n\nGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.\n\n**Note: You can only move either down or right at any point in time.**\n```\nExample:\n\nInput:\n[\n  [1,3,1],\n  [1,5,1],\n  [4,2,1]\n]\n\nOutput: 7\n\nExplanation: Because the path 1→3→1→1→1 minimizes the sum.\n```\n### Implementation 1 : Mutating input array , Time : O(rows * columns) , Space : O(1)\n```java\nclass Solution {\n    public int minPathSum(int[][] grid) {\n        if(grid == null || grid.length == 0)\n            return 0;\n        int rows = grid.length, columns = grid[0].length;\n        for(int col = 1; col \u003c columns; col++) {\n            grid[0][col] += grid[0][col-1]; \n        }\n        for(int row = 1; row \u003c rows; row++) {\n            grid[row][0] += grid[row-1][0];\n        }\n        for(int row = 1; row \u003c rows; row++) {\n            for(int col = 1; col \u003c columns; col++) {\n                grid[row][col] += Math.min(grid[row-1][col], grid[row][col-1]);\n            }\n        }\n        return grid[rows-1][columns-1];\n    }\n}\n```\n\n### Implementation 2 : Without Mutation  , Time : O(rows * columns) , Space : O(rows * columns)\n```java\nclass Solution {\n    public int minPathSum(int[][] grid) {\n        if(grid == null || grid.length == 0)\n            return 0;\n        int rows = grid.length, columns = grid[0].length;\n        int[][] dp = new int[rows][columns];\n        dp[0][0] = grid[0][0];\n        for(int col = 1; col \u003c columns; col++) {\n            dp[0][col] = dp[0][col-1] + grid[0][col]; \n        }\n        for(int row = 1; row \u003c rows; row++) {\n            dp[row][0] = dp[row-1][0] + grid[row][0];\n        }\n        for(int row = 1; row \u003c rows; row++) {\n            for(int col = 1; col \u003c columns; col++) {\n                dp[row][col] = Math.min(dp[row-1][col], dp[row][col-1]) + grid[row][col];\n            }\n        }\n        return dp[rows-1][columns-1];\n    }\n}\n```\n\n# References :\nhttps://github.com/eMahtab/unique-paths\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fminimum-path-sum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femahtab%2Fminimum-path-sum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fminimum-path-sum/lists"}