id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "const int mod = 1e9 + 7;\nint dp[1001][1001][2];\n\nclass Solution {\npublic:\n int n, m;\n int f(int i, int j, bool flag, vector<vector<int>>& grid)\n {\n int ttl = 0;\n\n if(dp[i][j][flag] != -1)\n return dp[i][j][flag];\n\n if(i > 0 && grid[i-1][j] > grid[i][j])\... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "#define ll long long \nint mod = 1e9+7;\nclass Solution {\npublic:\n vector<int>dx={-1,1,0,0};\n vector<int>dy={0,0,-1,1}; \n ll dp[1001][1001];\n ll solve(int i,int j,int n,int m,vector<vector<int>>& grid){\n ll ans = 1;\n \n if(dp[i][j]!=-1) return dp[i][j];\n\n fo... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "using ll = long long;\nusing pl = pair<ll, ll>;\nusing vl = vector<ll>;\nusing vvl = vector<vector<ll>>;\nusing vll = vector<pair<ll, ll>>;\n\n#define all(a) a.begin(), a.end()\n#define rall(a) a.rbegin(), a.rend()\n\nclass Solution {\npublic:\n\nconst ll dx[4] = {-1,1,0,0};\nconst ll dy[4] = {0,0,-1,1};\n... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "class Solution {\npublic:\n using ll = long long;\n const int mod = 1e9+7;\n int countPaths(vector<vector<int>>& g) {\n vector<pair<int,int>> mvs = {{-1,0},{1,0},{0,1},{0,-1}};\n int n = g.size(),m = g[0].size();\n auto isvalid = [&](int x,int y)->bool{\n return x>=... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "class Solution {\npublic:\n void dfs(int i,int j,vector<vector<bool>>&visited,vector<vector<long long int>>&v,vector<vector<int>>&grid,vector<int>&v1,vector<int>&v2){\n int m=grid.size();\n int n=grid[0].size();\n visited[i][j]=1;\n for(int p=0;p<4;p++){\n int a=v1... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "#define MOD 1000000007\nclass Solution {\npublic:\n void dfs(vector<vector<int>>&grid,int row,int col,vector<vector<int>>&vis,vector<vector<long long>>&dp){\n vis[row][col]=1;\n dp[row][col]=1;\n int dr[4]={1,0,-1,0};\n int dc[4]={0,-1,0,1};\n for(int k=0;k<4;k++){\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "#define MOD 1000000007\nclass Solution {\npublic:\n void dfs(vector<vector<int>>&grid,int row,int col,vector<vector<int>>&vis,vector<vector<long long>>&dp){\n vis[row][col]=1;\n dp[row][col]=1;\n int dr[4]={1,0,-1,0};\n int dc[4]={0,-1,0,1};\n for(int k=0;k<4;k++){\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "constexpr int MOD = (int) 1e9 + 7;\n\nclass Solution {\nprivate:\n const vector<vector<int>>* grid;\n int width;\n int height;\n vector<vector<int>> cache;\n\npublic:\n int countPaths(vector<vector<int>>& grid) {\n this->grid = &grid;\n width = grid[0].size();\n height =... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "class Solution {\npublic:\n \n int mod = 1e9 + 7;\n \n int rec(int i, int j, int n, int m, vector<vector<int>> &grid, vector<vector<int>> &dp){\n \n if(dp[i][j] != -1) return dp[i][j];\n \n int ans = 1;\n \n if(j - 1 >= 0 && grid[i][j] < grid[i][j-1]){\... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "class Solution {\npublic:\n vector<int> rows={0,-1,0,1};\n vector<int> cols={-1,0,1,0};\n int fun(int i,int j,vector<vector<int>> &grid,vector<vector<int>> &dp)\n {\n if(dp[i][j]!=-1)\n return dp[i][j];\n int sum=0,e=1e9+7;\n for(int k=0;k<4;k++)\n {\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "class Solution {\npublic:\n int l = 1e9+7;\n int dyna(vector<vector<int>>& dp, vector<vector<int>>& grid, int i, int j){\n if(dp[i][j]!=-1){\n return dp[i][j];\n }\n int n = grid.size();\n int m = grid[0].size();\n long long ans = 1;\n if(j+1<m && ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "class Solution {\npublic:\n #define MOD (int)(1E9 + 7)\n vector<int> axis{ 0, -1, 0, 1, 0 };\n int m, n;\n int dp[1001][1001];\n int dfs(int i, int j, vector<vector<int>>& matrix, int prev) {\n if(i < 0 || j < 0 || i == m || j == n || matrix[i][j] <= prev) return 0;\n if(dp[i][... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "class Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n int n = grid.size(), m = grid[0].size(), x, y, r, c;\n int md = 1e9 + 7;\n vector<vector<int>> inDeg(n, vector<int> (m, 0));\n vector<vector<int>> store(n, vector<int> (m, 1));\n vector<pair<int,... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "class Solution {\npublic:\n int dp[1005][1005];\n int dy[4]={1,-1,0,0};\n int dx[4]={0,0,1,-1};\n int mod=1e9+7;\n long long solve(vector<vector<int>>&v,int x,int y)\n {\n if(dp[x][y]!=-1)return dp[x][y];\n int n=v.size();\n int m=v[0].size();\n long long ans=1... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 2 | {
"code": "class Solution {\npublic:\n int n;\n int m;\n int t[1001][1001];\n vector<vector<int>>directions{{0,1}, {0,-1}, {-1,0}, {1,0}};\n long long M = 1e9 + 7;\n bool issafe(int i, int j)\n {\n return (i >= 0 && i < m && j >= 0 && j < n);\n }\n int solve(int i, int j, vector<vect... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int mod=1e9+7;\n vector<int>dx={0,0,1,-1};\n vector<int>dy={1,-1,0,0};\n\n int getPaths(vector<vector<int>>& grid,vector<vector<int>>& dp,int row,int col){\n int rows=grid.size();\n int cols=grid[0].size();\n int valHere= grid[row][col];\n if(dp[row][col]!... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int mod=1e9+7;\n vector<int>dx={0,0,1,-1};\n vector<int>dy={1,-1,0,0};\n\n int getPaths(vector<vector<int>>& grid,vector<vector<int>>& dp,int row,int col){\n int rows=grid.size();\n int cols=grid[0].size();\n int valHere= grid[row][col];\n if(dp[row][col]!... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "// class Solution {\n// private:\n// const int MOD = 1e9 + 7;\n// public:\n// int countPaths(vector<vector<int>>& grid) {\n// int nrows=grid.size();\n// int ncols=grid[0].size();\n\n// vector<vector<int>> memo(nrows,vector<int> (ncols,-1));\n// long long result=0;\n\... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int MOD = 1e9 + 7;\n int countPaths(vector<vector<int>>& grid) {\n int m = grid.size(), n = grid[0].size();\n vector<vector<int>> dp(m, vector<int>(n, 1));\n vector<pair<int, int>> cells;\n \n for (int i = 0; i < m; ++i) {\n fo... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n pair<int,int> dir[4] = {{0,1},{0,-1},{-1,0},{1,0}};\n int MOD = 1e9+7;\n int dfs(int r,int c, vector<vector<int>>& vis, vector<vector<int>>& dp, vector<vector<int>>& grid ){\n\n vis[r][c] = 1;\n int m = grid.size();\n int n = grid[0].size();\n\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "#define ll long long\nclass Solution {\npublic:\n ll m,n;\n ll mod=1e9+7;\n ll dp[1005][1005],a[1005][1005],vis[1005][1005];\n ll dx[4]={1,-1,0,0};\n ll dy[4]={0,0,1,-1};\n void dfs(ll x,ll y){\n if(vis[x][y])\n return;\n vis[x][y]=1;\n dp[x][y]=1;\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n int n = grid.size(), m = grid[0].size();\n vector<vector<long long>> dp(n, vector<long long>(m, 0));\n \n auto customOp = [&grid] (const pair<int, int> l, const pair<int, int> r) -> bool {\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n int n = grid.size(), m = grid[0].size();\n vector<vector<long long>> dp(n, vector<long long>(m, 0));\n long long MOD = (int)(pow(10, 9) + 7);\n auto customOp = [&grid] (const pair<int, int> l, const pai... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> vis,a,dp;\n int n,m;\n const int mod = 1e9+7;\n vector<int> dx = {0,0,-1,1};\n vector<int> dy = {-1,1,0,0};\n bool isValid(int i,int j){\n return i>=0 && j>=0 && i<n && j<m && !vis[i][j];\n }\n int dfs(int i,int j){\n if(... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int dx[4]={-1,1,0,0};\n int dy[4]={0,0,1,-1};\n bool isValid(int x,int y,int n,int m){\n return (x>=0&&y>=0&&x<n&&y<m);\n }\n int countPaths(vector<vector<int>>& grid) {\n // it is just like a toposort\n // all nodes with large values appears... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int mod = 1e9 + 7;\n vector<pair<int,int>> dir{{-1,0}, {1, 0}, {0, 1}, {0, -1}};\n int countPaths(vector<vector<int>>& arr) {\n int n = arr.size(), m = arr[0].size();\n vector<vector<long>> paths(n, vector<long>(m, 1));\n vector<vector<int>> inDegre... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int mod_val = pow(10,9) + 7;\n\n int dfs_on_node(vector<vector<int>>& grid, vector<vector<int>>& dp, int n, int m, int x, int y){\n // Already visited\n if (dp[x][y] != -1) return dp[x][y];\n\n // Check all 4 directions\n int paths[4][2] = {{0, ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int mod_val = pow(10,9) + 7;\n\n int dfs_on_node(vector<vector<int>>& grid, vector<vector<int>>& dp, int n, int m, int x, int y){\n // Already visited\n if (dp[x][y] != -1) return dp[x][y];\n\n // Check all 4 directions\n int paths[4][2] = {{0, ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "\n#define ll long long\nclass Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n \n static const int MOD = 1000000007;\n \n int m = grid.size(), n = grid[0].size(), p ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "\n#define ll long long\nclass Solution {\npublic:\n static const int MOD = 1000000007;\n int countPaths(vector<vector<int>>& grid) {\n \n int m = grid.size(), n = grid[0].size(), p = m * n + 1;\n vector<vector<ll>> dp(m, vector<ll>(n, -1));\n \n vector<vector<int>> ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n bool valid(long long x,long long y,long long n,long long m){\n if(x>=0&&y>=0&&x<n&&y<m)return true;\n return false;\n }\n void dfs(long long x,long long y, vector<vector<int>>& k,vector<vector<bool>>& vis,vector<vector<long long>>& dp,long long n,long long... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n bool valid(long long x,long long y,long long n,long long m){\n if(x>=0&&y>=0&&x<n&&y<m)return true;\n return false;\n }\n void dfs(long long x,long long y, vector<vector<int>>& k,vector<vector<bool>>& vis,vector<vector<long long>>& dp,long long n,long long... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "using ll = long long;\nclass Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n ll n = grid.size(), m = grid[0].size(), ans = 0, mod = 1e9+7;\n vector<vector<ll>> dp(n + 1, vector<ll> (m + 1, -1));\n auto add = [&](ll a, ll b){\n return ((a%mod) + (b%mod)... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n const int MOD = 1e9 + 7;\n unordered_map<string, int> mp;\n int dirx[4] = {0, 0, 1, -1};\n int diry[4] = {1, -1, 0, 0};\n int countPath(int i, int j, vector<vector<int>>& grid, int row, int col, string temp, vector<vector<int>> &dp) {\n if(dp[i][j] != -1) r... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n const int MOD = 1e9 + 7;\n unordered_map<string, int> mp;\n int dirx[4] = {0, 0, 1, -1};\n int diry[4] = {1, -1, 0, 0};\n int countPath(int i, int j, vector<vector<int>>& grid, int row, int col, string temp, vector<vector<int>> &dp) {\n if(dp[i][j] != -1) r... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\n vector<vector<int>> dp;\n vector<vector<int>> moves = {{0,1},{0,-1},{1,0},{-1,0}};\n int mod = 1e9+7;\n int res = 0;\npublic:\n int dfs(vector<vector<int>> &grid,int i,int j,vector<vector<bool>> &visited) {\n int m = grid.size(), n = grid[0].size();\n if(dp[i... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\n vector<vector<int>> dp;\n vector<vector<int>> moves = {{0,1},{0,-1},{1,0},{-1,0}};\n int mod = 1e9+7;\npublic:\n int dfs(vector<vector<int>> &grid,int i,int j,vector<vector<bool>> &visited) {\n int m = grid.size(), n = grid[0].size();\n if(dp[i][j]!=-1) return d... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int dfs(vector<vector<int>>& grid, vector<vector<int>>& dp, int i, int j) {\n int mod = 1e9 + 7;\n if (dp[i][j] != -1) {\n return dp[i][j];\n }\n long long paths = 1; \n vector<pair<int, int>> arr = {{1, 0}, {-1, 0}, {0, 1}, {0, -... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int dfs(vector<vector<int>>& grid, vector<vector<int>>& dp, int i, int j) {\n int mod = 1e9 + 7;\n if (dp[i][j] != -1) {\n return dp[i][j];\n }\n long long paths = 1; \n vector<pair<int, int>> arr = {{1, 0}, {-1, 0}, {0, 1}, {0, -... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int vis[1001][1001];\n int mod = 1e9+7;\n int dfs(vector<vector<int>>& grid, int i, int j){\n if(vis[i][j])return vis[i][j];\n int ans = 1;\n vector<pair<int,int>>dir = {{-1,0},{1,0},{0,1},{0,-1}};\n for(auto d:dir){\n int x = i+d.... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "typedef long long ll;\nconst ll M = 1e9+7;\nclass Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n int n = grid.size();\n int m = grid[0].size();\n vector<vector<ll>> dp(n, vector<ll>(m,-1));\n\n function<ll(int,int)> dfs = [&](int i, int j) {\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n\n int mod = 1e9+7;\n\n unordered_map<int, unordered_map<int, int>> mp;\n int solve(vector<vector<int>>& grid, int endx, int endy){\n if(mp.contains(endx) && mp[endx].contains(endy)){\n return mp[endx][endy];\n }\n int ret = 1;\n if... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int mod = 1e9 + 7;\n map<pair<int, int>, int> mp;\n int dfs(int i, int j, int n, int m, vector<vector<int> > &grid)\n {\n if(mp.find({i, j}) != mp.end())return mp[{i, j}];\n int res = 1;\n\n int delRow[] = {-1, 0, 1, 0};\n int delCol[] = {... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int mod = 1e9 + 7;\n map<pair<int, int>, int> dp;\n int dfs(int i, int j, int n, int m, vector<vector<int> > &grid)\n {\n if(dp.find({i, j}) != dp.end())return dp[{i, j}];\n int res = 1;\n\n int delRow[] = {-1, 0, 1, 0};\n int delCol[] = {... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "typedef pair<int,int> pi;\nclass Solution {\n int rows, cols;\n vector<int> dx = {1,0,-1,0};\n vector<int> dy = {0,-1,0,1};\n const int MOD = 1e9 + 7;\n\n int dfs(pi val, vector<vector<int>> &d, map<pi, int> &memo) {\n memo[val] = 1;\n\n int depth(1);\n for(int o = 0; o ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n unordered_map<int,unordered_map<int,int>> dp;\n vector<vector<int>> a;\n int m,n;\n vector<int> dir{0,1,0,-1,0};\n int mod=1e9+7;\n int dfs(int x,int y)\n {\n if(dp.find(x)!=dp.end() && dp[x].find(y)!=dp[x].end())\n return dp[x][y];\n \... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int mod = 1e9+7;\n int dfs (int x,int y,vector<vector<int>>&grid,map<pair<int,int>,int>&d,int p) {\n int n=grid.size();\n int m=grid[0].size();\n if(x>=0&&x<n&&y>=0&&y<m) {\n if(grid[x][y]<=p) {\n return 0;\n }\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int dx[4]={-1,1,0,0};\n int dy[4]={0,0,-1,1};\n const int mod=1e9+7;\n bool check(int i,int j,int n,int m){\n if(i>=0 && j>=0 && i<n && j<m) \n return true;\n return false;\n }\n void dfs(int node,vector<int>&dp,vector<int>adj[]){\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\nprivate:\n const int mod=1e9+7;\n int dfs(int i, int j, vector<vector<int>>& grid, vector<int>& dp){\n int m=grid.size();\n int n=grid[0].size();\n if(dp[i*n+j]!=-1) return dp[i*n+j];\n int ans=1;\n vector<int> dx={-1,1,0,0};\n vector<int> d... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int solve(vector<vector<int> > &grid,int i,int j,vector<vector<int>> &dp){\n int ans=1;\n if(dp[i][j] != -1){\n return dp[i][j];\n }\n vector<int> dx={-1,0,0,1};\n vector<int> dy={0,-1,1,0};\n for(int k=0;k<4;k++){\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int solve(vector<vector<int> > &grid,int i,int j,vector<vector<int>> &dp){\n int ans=1;\n if(dp[i][j] != -1){\n return dp[i][j];\n }\n int n=grid.size();\n int m=grid[0].size();\n vector<int> dx={-1,0,0,1};\n vector<... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "int mod = 1000000007;\nclass Solution {\npublic:\n int paths(int i, int j, vector<vector<int>>& grid, vector<vector<int>>& dp) {\n int n = grid.size();\n int m = grid[0].size();\n if(i < 0 || i >= n || j < 0 || j >= m) return 0;\n if(dp[i][j] != -1) return dp[i][j];\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\n int mod = 1e9 + 7;\npublic: \n int solve(vector<vector<int>>&grid,int i, int j,vector<vector<int>>&dp)\n {\n \n int n = grid.size();\n int m = grid[0].size();\n int count = 1;\n if(dp[i][j] != -1) return dp[i][j];\n vector<int>delrow = {... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\n int mod = 1e9 + 7;\npublic: \n int solve(vector<vector<int>>&grid,int i, int j,vector<vector<int>>&dp)\n {\n \n int n = grid.size();\n int m = grid[0].size();\n int count = 1; //for counting the cell itself\n if(dp[i][j] != -1) return dp[i][j]... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int mod=1e9+7;\n int dp[1001][1001];\n int helper(vector<vector<int>>& grid,int &x,int &y){\n if(dp[x][y]!=-1){\n return dp[x][y];\n }\n int m=grid.size();\n int n=grid[0].size();\n long long count=1;\n vector<pair<in... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\nint mod=1e9+7;\nint helper(vector<vector<int>>& mat, vector<vector<int>>& dp, int i,int j)\n {\n if(dp[i][j]!=-1) return dp[i][j];\n vector<pair<int,int>> delta={{0,-1},{-1,0},{0,1},{1,0}};\n int maxi=1;\n for(auto it:delta)\n {\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int mod=1e9+7;\n int helper(vector<vector<int>>& grid,int &x,int &y,vector<vector<int>> &dp){\n if(dp[x][y]!=-1){\n return dp[x][y];\n }\n int m=grid.size();\n int n=grid[0].size();\n long long count=1;\n vector<pair<int... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int mod=1e9+7;\n int helper(vector<vector<int>>& grid,int &x,int &y,vector<vector<int>> &dp){\n if(dp[x][y]!=-1){\n return dp[x][y];\n }\n int m=grid.size();\n int n=grid[0].size();\n long long count=1;\n vector<pair<int... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n int n = grid.size();\n int m = grid[0].size();\n int mod = 1e9+7;\n\n map<pair<int,int>,int>map1;\n vector<pair<int,pair<int,int>>> v1;\n for(int i = 0; i<n; i++)\n {\n f... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n int m = grid.size(), n = grid[0].size();\n\n int DIR[5] = {0,1,0,-1,0}; \n int mod = 1e9 + 7; \n vector<vector<int>> adj(n*m);\n vector<int> indeg(n*m, 0), dp(n*m, 1);\n\n for(int i=0; i<m... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int MOD = 1e9 + 7;\n vector<int> dir = {-1, 0, 1, 0, -1};\n int countPaths(vector<vector<int>>& grid) {\n int m = grid.size();\n int n = grid[0].size();\n vector<vector<int>> vec; \n for(int i = 0; i < m; i++){\n for(int j = 0; j <... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n int n = grid.size(),m = grid[0].size();\n vector<vector<int>>pq;\n vector<vector<long long>>dp(n,vector<long long>(m,1));\n for(int i=0;i<n;i+=1){\n for(int j=0;j<m;j+=1)pq.push_back({grid[i]... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n int n = grid.size();\n int m = grid[0].size();\n vector<vector<long long>> dp(n, vector<long long>(m, 1));\n priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "template <class T>\nostream &operator<<(ostream &os, const vector<vector<T>> &mat) {\n for (auto &line : mat) {\n os << \"[\";\n for (auto &item : line) {\n os << item << \",\";\n }\n os << \"]\\n\";\n }\n return os;\n}\n\nclass Solution {\npublic:\n int countPaths(vector<vector<int>> ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "int mod=1e9+7;\nbool check(int i,int j,int n,int m)\n{\n if(i<0||j<0||i>=n||j>=m)\n return false;\n return true;\n}\nint dfs(int i,int j,vector<vector<int>>& grid,vector<vector<int>>&dp)\n{\n int n=grid.size();\n int m=grid[0].size();\n if(dp[i][j]!=-1)return dp[i][j];\n\n vector<int>r... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n const int mod = 1e9 + 7;\n\n int dfs(vector<vector<int>>& grid, vector<vector<int>>& dp, int i, int j){\n if(i<0 or j<0 or i>=grid.size() or j>=grid[0].size())return 0;\n if(dp[i][j]!=-1)return dp[i][j];\n int cnt = 1;\n vector<int> dx = {0,0,1,... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n int n = grid.size(),m = grid[0].size();\n vector<vector<int>> dp (n,vector<int>(m,1));\n map<int,vector<pair<int,int>>> M;\n for(int i=0;i<n;i++){\n for(int j=0;j<m;j++){\n M[g... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "int cmp(vector<int>&a, vector<int>&b){\n return a[0]<b[0];\n}\nclass Solution {\npublic:\n int mod=1e9+7;\n int res=0;\n int dfs(int i, int j,int e1,int e2, vector<vector<int>>&grid,vector<vector<int>>&dp){\n // if(i==e1 && j==e2)return 1;\n int n=grid.size(),m=grid[0].size();\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "int cmp(vector<int>&a, vector<int>&b){\n return a[0]<b[0];\n}\nclass Solution {\npublic:\n int mod=1e9+7;\n int res=0;\n int dfs(int i, int j, vector<vector<int>>&grid,vector<vector<int>>&dp){\n // if(i==e1 && j==e2)return 1;\n int n=grid.size(),m=grid[0].size();\n if(dp[i]... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n void dfs(int i,int j,vector<vector<int>>&vis,vector<vector<vector<pair<int,int>>>>&adj,stack<pair<int,int>>&st)\n {\n //cout<<i<<\" \"<<j<<endl;\n vis[i][j]=1;\n for(auto it:adj[i][j])\n {\n int i1=it.first,j1=it.second;\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n void dfs(int i,int j,vector<vector<int>>&vis,vector<vector<vector<pair<int,int>>>>&adj,stack<pair<int,int>>&st)\n {\n //cout<<i<<\" \"<<j<<endl;\n vis[i][j]=1;\n for(auto it:adj[i][j])\n {\n int i1=it.first,j1=it.second;\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int countPaths(vector<vector<int>>& grid) {\n int m = grid.size(), n = grid[0].size();\n int count = 0;\n int mod = 1e9 + 7;\n vector<int> dr = {1, -1, 0, 0};\n vector<int> dc = {0, 0, 1, -1};\n set<pair<int, int>> path;\n vect... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\nconst long long M=1e9+7;\nvector<long long>d1 ={-1,1,0,0};\nvector<long long>d2 ={0,0,1,-1};\nvector<vector<long long>>visited;\nvector<vector<long long>>dp;\nlong long ans;\nvoid dfs(long long i, long long j, vector<vector<vector<pair<long long,long long>>>>&adj){\n visited[i][j]=1;\n... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int M = 1e9+7;\n bool inRange(vector<vector<int>> &grid, int i , int j){\n int n = grid.size();\n int m = grid[0].size();\n if(i>=0 && j >=0 && i <n && j <m){\n return true;\n }\n return false;\n }\n bool checkMax(vector<... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n const int MAX=1e5,mod=1e9+7;\n vector<pair<int,int>>trans={{0,1},{0,-1},{1,0},{-1,0}};\n int countPaths(vector<vector<int>>& grid) {\n vector<vector<pair<int,int>>>v(MAX+1);\n int n=grid.size();\n int m=grid[0].size();\n for(int i=0;i<n;i++)\... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int m,n;\n //long long mod = 1e9+7;\n const int mod = 1e9+7;\n vector<vector<int>>directions = {\n {-1,0} ,{0,-1},{0,1},{1,0}\n };\n\n bool isSafe(int i ,int j){\n return (i<m && i>=0 && j<n && j>=0);\n }\n int t[1001][1001];\n int dfs(ve... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n\n int dp[1001][1001];\n int m,n;\n int mod = 1e9+7;\n vector<vector<int>> dirs = {{-1,0},{1,0},{0,1},{0,-1}};\n\n int dfs(vector<vector<int>>& grid,int i,int j){\n if(dp[i][j]!=-1) return dp[i][j];\n int ans = 1;\n for(auto dir:dirs){\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int dp[1001][1001];\n bool isSafe(int i,int j,vector<vector<int>>&grid){\n int n=grid.size();\n int m=grid[0].size();\n return i>=0&&i<n&&j>=0&&j<m;\n }\n vector<vector<int>>directions={{-1,0},{1,0},{0,1},{0,-1}};\n int dfs(int i,int j,vector<... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int m,n;\n int mod = 1e9+7;\n vector<vector<int>> dir={{-1,0},{0,1},{1,0},{0,-1}};\n bool issafe(int i,int j){\n return i>=0 && i<m && j>=0 && j<n;\n }\n int solve(vector<vector<int>>& grid, int i,int j,vector<vector<int>>& dp){\n int result = 1;\... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dirc = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};\n\n int dfs(int i, int j, vector<vector<int>>& matrix, vector<vector<int>>& dp) {\n int n = matrix.size();\n int m = matrix[0].size();\n\n if(dp[i][j] != -1) return dp[i][j];\n\n int... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dirc = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};\n\n int dfs(int i, int j, vector<vector<int>>& matrix, vector<vector<int>>& dp) {\n int n = matrix.size();\n int m = matrix[0].size();\n\n if(dp[i][j] != -1) return dp[i][j];\n\n int... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n int m,n;\n int mod=1e9+7;\n vector<vector<int>>directions{{-1,0},{1,0},{0,-1},{0,1}};\n int recurssion(int row,int col,vector<vector<int>>& matrix,vector<vector<int>>&dp){\n if(dp[row][col]!=-1) return dp[row][col];\n int count=1;\n for(auto it:d... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>> dirs = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};\n const int MOD = 1e9+7;\n\n int solve(int i, int j, vector<vector<int>>& grid, vector<vector<int>>& dp, int n, int m) {\n if(dp[i][j] != -1) return dp[i][j]; // If already computed, return stored re... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\n vector<vector<int>>directions{{1,0}, {0,1}, {-1,0},{0,-1}};\n int MOD = 1000000007;\n int helper(int i, int j, int rows, int cols, vector<vector<int>>&grid, vector<vector<int>>&dp){\n if(dp[i][j] != -1)\n return dp[i][j];\n int maxPath = 1;\n ... |
2,409 | <p>You are given an <code>m x n</code> integer matrix <code>grid</code>, where you can move from a cell to any adjacent cell in all <code>4</code> directions.</p>
<p>Return <em>the number of <strong>strictly</strong> <strong>increasing</strong> paths in the grid such that you can start from <strong>any</strong> cell a... | 3 | {
"code": "class Solution {\npublic:\nint mod=1e9+7;\nvector<vector<int>> arr={{0,1},{1,0},{-1,0},{0,-1}};\nint fun(int i,int j,vector<vector<int>>& grid,vector<vector<int>> &dp){\n int n=grid.size();\n int m=grid[0].size();\n if(dp[i][j]!=-1)\n return dp[i][j];\n long long sum=0;\n for(auto it: a... |
2,416 | <p>You are given the <code>root</code> of a <strong>full binary tree</strong> with the following properties:</p>
<ul>
<li><strong>Leaf nodes</strong> have either the value <code>0</code> or <code>1</code>, where <code>0</code> represents <code>False</code> and <code>1</code> represents <code>True</code>.</li>
<li><s... | 0 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,416 | <p>You are given the <code>root</code> of a <strong>full binary tree</strong> with the following properties:</p>
<ul>
<li><strong>Leaf nodes</strong> have either the value <code>0</code> or <code>1</code>, where <code>0</code> represents <code>False</code> and <code>1</code> represents <code>True</code>.</li>
<li><s... | 0 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,416 | <p>You are given the <code>root</code> of a <strong>full binary tree</strong> with the following properties:</p>
<ul>
<li><strong>Leaf nodes</strong> have either the value <code>0</code> or <code>1</code>, where <code>0</code> represents <code>False</code> and <code>1</code> represents <code>True</code>.</li>
<li><s... | 0 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,416 | <p>You are given the <code>root</code> of a <strong>full binary tree</strong> with the following properties:</p>
<ul>
<li><strong>Leaf nodes</strong> have either the value <code>0</code> or <code>1</code>, where <code>0</code> represents <code>False</code> and <code>1</code> represents <code>True</code>.</li>
<li><s... | 0 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,416 | <p>You are given the <code>root</code> of a <strong>full binary tree</strong> with the following properties:</p>
<ul>
<li><strong>Leaf nodes</strong> have either the value <code>0</code> or <code>1</code>, where <code>0</code> represents <code>False</code> and <code>1</code> represents <code>True</code>.</li>
<li><s... | 0 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,416 | <p>You are given the <code>root</code> of a <strong>full binary tree</strong> with the following properties:</p>
<ul>
<li><strong>Leaf nodes</strong> have either the value <code>0</code> or <code>1</code>, where <code>0</code> represents <code>False</code> and <code>1</code> represents <code>True</code>.</li>
<li><s... | 0 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,416 | <p>You are given the <code>root</code> of a <strong>full binary tree</strong> with the following properties:</p>
<ul>
<li><strong>Leaf nodes</strong> have either the value <code>0</code> or <code>1</code>, where <code>0</code> represents <code>False</code> and <code>1</code> represents <code>True</code>.</li>
<li><s... | 1 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,416 | <p>You are given the <code>root</code> of a <strong>full binary tree</strong> with the following properties:</p>
<ul>
<li><strong>Leaf nodes</strong> have either the value <code>0</code> or <code>1</code>, where <code>0</code> represents <code>False</code> and <code>1</code> represents <code>True</code>.</li>
<li><s... | 1 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,006 | <p>There are <code>n</code> students in a class numbered from <code>0</code> to <code>n - 1</code>. The teacher will give each student a problem starting with the student number <code>0</code>, then the student number <code>1</code>, and so on until the teacher reaches the student number <code>n - 1</code>. After that,... | 0 | {
"code": "inline unsigned long long accum(string &s) {\n unsigned long long acc = 0;\n unsigned long long number = 0;\n for (char* c = &s[1]; *c != '\\0'; c++) {\n if (*c >= 48 && *c <= 57) {\n number = number * 10 + (*c & 15);\n } else {\n acc += number;\n num... |
2,006 | <p>There are <code>n</code> students in a class numbered from <code>0</code> to <code>n - 1</code>. The teacher will give each student a problem starting with the student number <code>0</code>, then the student number <code>1</code>, and so on until the teacher reaches the student number <code>n - 1</code>. After that,... | 0 | {
"code": "inline unsigned long long accum(string &s) {\n unsigned long long acc = 0;\n unsigned long long number = 0;\n for (char* c = &s[1]; *c != '\\0'; c++) {\n if (*c >= 48 && *c <= 57) {\n number = number * 10 + (*c & 15);\n } else {\n acc += number;\n num... |
2,006 | <p>There are <code>n</code> students in a class numbered from <code>0</code> to <code>n - 1</code>. The teacher will give each student a problem starting with the student number <code>0</code>, then the student number <code>1</code>, and so on until the teacher reaches the student number <code>n - 1</code>. After that,... | 0 | {
"code": "inline unsigned long long accum(string &s) {\n unsigned long long acc = 0;\n unsigned long long number = 0;\n for (char* c = &s[1]; *c != '\\0'; c++) {\n if (*c >= 48 && *c <= 57) {\n number = number * 10 + (*c & 15);\n } else {\n acc += number;\n num... |
2,006 | <p>There are <code>n</code> students in a class numbered from <code>0</code> to <code>n - 1</code>. The teacher will give each student a problem starting with the student number <code>0</code>, then the student number <code>1</code>, and so on until the teacher reaches the student number <code>n - 1</code>. After that,... | 0 | {
"code": "inline unsigned long long vecfromstr(std::string& s, std::vector<unsigned long long>& chalk) {\n unsigned long long number = 0;\n unsigned long long prev_number = 0;\n chalk.clear();\n for (char* c = &s[1]; *c != '\\0'; c++) {\n if (*c >= 48 && *c <= 57) {\n number = number * ... |
2,006 | <p>There are <code>n</code> students in a class numbered from <code>0</code> to <code>n - 1</code>. The teacher will give each student a problem starting with the student number <code>0</code>, then the student number <code>1</code>, and so on until the teacher reaches the student number <code>n - 1</code>. After that,... | 0 | {
"code": "inline unsigned long long vecfromstr(std::string& s, std::vector<unsigned long long>& chalk) {\n unsigned long long number = 0;\n unsigned long long prev_number = 0;\n chalk.clear();\n for (char* c = &s[1]; *c != '\\0'; c++) {\n if (*c >= 48 && *c <= 57) {\n number = number * ... |
2,006 | <p>There are <code>n</code> students in a class numbered from <code>0</code> to <code>n - 1</code>. The teacher will give each student a problem starting with the student number <code>0</code>, then the student number <code>1</code>, and so on until the teacher reaches the student number <code>n - 1</code>. After that,... | 0 | {
"code": "// class Solution {\n// public:\n// int chalkReplacer(vector<int>& chalk, int initialChalkPieces) {\n// long long totalChalkNeeded = 0;\n// for (int studentChalkUse : chalk)\n// {\n// totalChalkNeeded += studentChalkUse;\n// }\n \n// int remain... |
2,006 | <p>There are <code>n</code> students in a class numbered from <code>0</code> to <code>n - 1</code>. The teacher will give each student a problem starting with the student number <code>0</code>, then the student number <code>1</code>, and so on until the teacher reaches the student number <code>n - 1</code>. After that,... | 0 | {
"code": "#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(\"03\")\n#pragma GCC target(\"avx\")\n#pragma GCC target(\"-fsplit-loops\")\n#pragma GCC target(\"tune=native\")\n\nstatic const auto fastIO = []() {\n std::ios::sync_with_stdio(false);\n std::cin.tie(nullptr);\n std::cout.tie(nullptr);\n re... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.