id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n bool isValid(int r , int c, int numRows, int numCols){\n return (r >= 0 && c >= 0 && r < numRows && c < numCols);\n }\n\n void dfs(vector<vector<int>>& land, vector<vector<bool>>& visited, vector<int>& result, int r, int c, int numRows, int numCols){\n if ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\nprivate:\n int m , n;\n void dfs(int row , int col , vector<vector<int>> &land , vector<vector<bool>> &visited , int &maxRow , int &maxCol , int &minRow ,int &minCol){\n visited[row][col] = true;\n maxRow = max(maxRow , row);\n maxCol = max(maxCol , col);\n ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n int n, m;\n void f(int i, int j, int count, vector<vector<int>>& land, vector<vector<int>>& visited, vector<vector<pair<int,int>>>& cordinates){\n if(i<0 || i>= n || j<0 || j>=m || land[i][j]==0 || visited[i][j]==1){\n return;\n }\n visited...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n void dfs(int i,int j,vector<vector<int>> &land,vector<vector<int>> &vis,vector<int>& temp){\n vis[i][j]=true;\n int n =land.size(),m=land[0].size();\n if(i < temp[0])temp[0]=i;\n if(i > temp[2])temp[2]=i;\n if(j < temp[1])temp[1]=j;\n ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\nint dx[4]={1,0,-1,0};\nint dy[4]={0,-1,0,1};\n vector<vector<int>>fans;\n \n int n,m;\n \n bool check(int nx, int ny, vector<vector<int>>& vis1){\n if(nx>=0&&nx<n&&ny>=0&&ny<m&&!vis1[nx][ny])return true;\n return false;\n}\n void df...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n void dfs(int row,int col,int &ansrow,int &anscol,vector<vector<int>>& land,vector<vector<int>> &vis)\n {\n int m=land.size();\n int n=land[0].size();\n vis[row][col]=1;\n vector<pair<int,int>> dir={{0,1},{0,-1},{1,0},{-1,0}};\n for(int i=...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n void dfs(int i, int j, vector<vector<int>>& visited, vector<vector<int>>& land, int &ei, int &ej) {\n int m = visited.size();\n int n = visited[0].size();\n\n visited[i][j] = 1;\n vector<int> dir_i = {1, 0, -1, 0};\n vector<int> dir_j = {0, ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>> findFarmland(vector<vector<int>>& land) {\n int n = land.size(), m = land[0].size();\n vector<vector<int>> ans ;\n int st = 0, en = 0;\n for (int i = 0; i < land.size(); i++) {\n for (int j = 0; j < land[0].size(); j+...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>> findFarmland(vector<vector<int>>& land) {\n int n = land.size();\n int m = land[0].size();\n vector<vector<int> > ans;\n \n\n for(int i=0;i<n;++i) {\n for(int j=0;j<m;++j) {\n if(land[i][j]) {\n ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>> findFarmland(vector<vector<int>>& land) {\n int dx[] = {-1, 1, 0, 0};\n int dy[] = {0, 0, -1, 1};\n int n = land.size();\n int m = land[0].size();\n vector<vector<int>> res;\n for(int i = 0; i < n; i++){\n ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\nprivate:\n bool isvalid(int x , int y, vector<vector<int>>& grid ){\n int m= grid.size();\n int n= grid[0].size();\n return x>=0 && x<m && y>=0 && y<n ;\n }\n void bfs(int i , int j ,vector<vector<int>>& land, int &r2 , int &c2 ){\n land[i][j]=0;\n ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n int m;\n int n;\n vector<vector<int>> directions{\n {1,0},\n {-1,0},\n {0,1},\n {0,-1}\n };\n\n //FUNCTION FOR DFS:\n void dfs(vector<vector<int>>& land,int i,int j,int& r2,int& c2)\n {\n if (i < 0 || i >= m || j < 0 || j >...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "//Hilal Parlakçı\nclass Solution {\nprivate:\n vector<vector<bool>> visited;\n int m, n;\n\n vector<int> dfs(int i, int j, vector<vector<int>>& grid) {\n vector<int> borders = {i, j, i, j};\n\n int coor_x[2] = {0, 1};\n int coor_y[2] = {1, 0};\n\n stack<pair<int, int>> ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n pair<int, int> bfs(vector<vector<int>>& land, int row, int col, vector<vector<bool>>& vis) {\n queue<pair<int, int>> que;\n que.push({row, col});\n vis[row][col] = true;\n int dirs[4][2] = {{0,-1}, {0,1}, {1,0}, {-1,0}};\n pair<int, int> cur...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>> findFarmland(vector<vector<int>>& land) {\n vector<vector<int>> ans;\n for(int i=0; i<land.size(); i++) {\n for(int j = 0; j<land[0].size(); j++) {\n if(land[i][j]) {\n pair<int ,int> p = findIslan...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<int> fun(int i, int j, vector<vector<int>>& land, vector<vector<int>>& vis) {\n vector<pair<int,int>> dirs = {{0,1}, {1,0}, {0,-1}, {-1,0}};\n vector<int> op = {i,j};\n for (auto dir: dirs) {\n int X = i + dir.first;\n int Y =...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>> findFarmland(vector<vector<int>>& land) {\n vector<vector<int>> vis(land.size(), vector<int>(land[0].size(), 0));\n vector<vector<int>> ans;\n int rr[4] = {1, -1, 0, 0};\n int cc[4] = {0, 0, -1, 1};\n \n for (int i...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "#include <vector>\n#include <queue>\nusing namespace std;\n\nclass Solution {\npublic:\n vector<vector<int>> findFarmland(vector<vector<int>>& land) {\n vector<vector<int>> ans;\n int rows = land.size();\n int cols = land[0].size();\n\n // Visited matrix to keep track of expl...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n bool isvalid(int i,int j,vector<vector<int>>&arr)\n {\n int m = arr.size();\n int n =arr[0].size();\n if(i>=0 and i<m and j>=0 and j<n)\n {\n return true;\n }\n return false;\n }\n vector<int>solve(int i,int j,vec...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>> findFarmland(vector<vector<int>>& land) {\n vector<vector<int>> ans;\n for(int i = 0; i < land.size(); i++)\n for(int j = 0; j < land[0].size(); j++)\n if(land[i][j]){\n vector<int> index = bfs(i, ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\nint dx[4]={-1,0,0,1};\nint dy[4]={0,-1,1,0};\nvector<vector<bool>>c;\nvector<int> dfs(int x,int y,vector<vector<int>>&land)\n{\n vector<int>row;\n queue<pair<int,int>>q;\n q.push({x,y});\n c[x][y]=true;\n int h1=x,h2=x,c1=y,c2=y;\n while(!q.empty())\n {\n ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n void bfs(vector<vector<int>>& grid1, vector<vector<bool>>& vis, int i,\n int j, vector<vector<int>>& ans) {\n queue<pair<int, int>> q;\n q.push({i, j});\n vis[i][j] = 1;\n vector<int> temp={i,j,i,j};\n while (!q.empty()) {\n ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\nvector<vector<int>> ans;\n// bool vis[301][301];\nint m, n;\nvector<vector<int>> possiblePaths = {{1,0},{0,1},{-1,0},{0,-1}};\n vector<vector<int>> findFarmland(vector<vector<int>>& land) {\n // memset(vis, 0, sizeof(vis));\n m=land.size(), n=land[0].size();\n ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<int> bfs(vector<vector<int>>& land, vector<vector<bool>>& visited, int r, int c) {\n int m = land.size();\n int n = land[0].size();\n queue<pair<int, int>> q;\n q.push({r, c});\n visited[r][c] = true;\n int r1 = r, c1 = c, r2 = r, c2 = c;\n \n vect...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\nprivate:\n vector<int> bfs(vector<vector<int>>& grid, int startRow, int startCol) {\n int n = grid.size();\n int m = grid[0].size();\n \n int bottomRow = startRow, bottomCol = startCol;\n queue<pair<int, int>> q;\n q.push({startRow, startCol});...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n\n vector<int> bfs(vector<vector<int>>& grid,int i,int j){\n\n int n=grid.size();\n int m=grid[0].size();\n\n vector<int>tv;\n\n queue<pair<int,int>>tq;\n tq.push({i,j});\n \n tv.insert(tv.end(),{i,j});\n\n int dx[]={...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n\n vector<vector<int>> direction={{-1,0},{1,0},{0,1},{0,-1}};\n vector<int> bfs(int i,int j,vector<vector<int>> &land, vector<vector<bool>> &visited ){\n vector<int> ans;\n int m=land.size();\n int n=land[0].size();\n queue<pair<int,int>> q;\n q.push({i,j});\n ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>> findFarmland(vector<vector<int>>& land) {\n // we will apply BFS\n vector<vector<int>> result;\n int row_num = land.size();\n int col_num = land[0].size();\n vector<vector<bool>> visited(row_num, vector<bool>(col_num, fal...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>> ans;\n int lx = -1, ly = -1;\n // int x[4] = {0, -1, 0, 1};\n // int y[4] = {-1, 0, 1, 0};\n // int x[4] = {0, 1, 0, -1};\n // int y[4] = {-1, 0, 1, 0};\n // int x[4] = {-1, 0, 1, 0};\n // int y[4] = {0, 1, 0, -1};\n int x[4] = {0, ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>> ans;\n int lx = -1, ly = -1;\n int x[4] = {0, -1, 0, 1};\n int y[4] = {-1, 0, 1, 0};\n\n int m, n;\n\n void f(int i, int j, vector<vector<int>> &land, vector<vector<int>> &vis){\n vis[i][j] = 1;\n queue<pair<int,int>> q;\n ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "#define FORESTLAND 0\n#define FARMLAND 1\n#define DISCOVERED_FARMLAND 2\n\nclass Solution {\npublic:\n\n /* =========================================================\n *\n * plot_farmland():\n *\n * Use BFS to map out entire group of farmland starting from...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n void bfs(vector<vector<int>>&land,int i,int j,pair<int,int>& top,pair<int,int>& bottom){\n int m = land.size(),n = land[0].size();\n int dx[] = {1,0,-1,0};\n int dy[] = {0,1,0,-1};\n queue<pair<int,int> >q;\n q.push({i,j});\n land[i]...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\nprivate:\n void bfs(vector<vector<int>> &land, vector<vector<bool>> &vis, int row, int col, vector<int> &temp){\n int n = land.size();\n int m = land[0].size();\n queue<pair<int, int>> q;\n q.push({row, col});\n vis[row][col] = true;\n pair<int...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\nprivate:\n void bfs(vector<vector<int>> &land, vector<vector<bool>> &vis, int row, int col, vector<int> &temp){\n int n = land.size();\n int m = land[0].size();\n queue<pair<int, int>> q;\n q.push({row, col});\n vis[row][col] = true;\n pair<int...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\nprivate:\n void bfs(int row, int col, vector<vector<int>>& vis, vector<vector<int>>& land, vector<int>& result) {\n vis[row][col] = 1;\n queue<pair<int, int>> q;\n q.push({row, col});\n\n int n = land.size();\n int m = land[0].size();\n\n int d...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n int m,n;\n vector<vector<int>>directions{{1,0},{-1,0},{0,1},{0,-1}};\n void dfs(vector<vector<int>>& land,int&l,int &r,int &i,int &j)\n {\n\n if(i<0 || j<0 || i>=m || j>=n || land[i][j]==0 )\n return;\n \n if(land[i][j]==-1)\n ...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<int> rows ={-1,1,0,0};\n vector<int> cols ={0,0,-1,1};\n vector<vector<int>> findFarmland(vector<vector<int>>& grid) {\n vector<vector<int>> ans;\n int n = grid.size();\n int m = grid[0].size();\n vector<vector<int>> visited(n,vector<i...
2,103
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> binary matrix <code>land</code> where a <code>0</code> represents a hectare of forested land and a <code>1</code> represents a hectare of farmland.</p> <p>To keep the land organized, there are designated rectangular areas of hectares that consist <strong...
3
{ "code": "class Solution {\npublic:\n vector<vector<int>> findFarmland(vector<vector<int>>& land) {\n int n=land.size();\n int m=land[0].size();\n vector<vector<int>> visited(n,vector<int>(m,0));\n vector<vector<int>> ans;\n for(int i=0;i<n;i++){\n for(int j=0;j<m;j++){...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
0
{ "code": "class Solution {\npublic:\n Solution(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n }\n\n struct comp{\n bool operator()(vector<int> &a, vector<int> &b){\n if(a[0]==b[0]) return a[1]>b[1];\n return a[0]<b[0];\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
0
{ "code": "class Solution {\npublic:\n Solution(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n }\n\n struct comp{\n bool operator()(vector<int> &a, vector<int> &b){\n if(a[0]==b[0]) return a[1]>b[1];\n return a[0]<b[0];\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
0
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int n = properties.size();\n sort(properties.begin(), properties.end(), [](vector<int>& a, vector<int>& b){\n if(a[0] == b[0]){\n return a[1] > b[1];\n }\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
0
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& arr) {\n sort(arr.begin(),arr.end(),[&](const auto& a, const auto& b){\n if(a[0] == b[0]){\n return a[1] > b[1];\n }\n return a[0]<b[0];\n });\n int ans = 0;\n...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
0
{ "code": "class Solution {\npublic:\n static bool comp (const vector<int>& lhs, const vector<int>& rhs) {\n return (lhs[0] == rhs[0] && lhs[1] < rhs[1]) || lhs[0] > rhs[0];\n }\n \n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n sort(properties.begin(), properties.end(), co...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
0
{ "code": "bool cmp(vector<int>& a, vector<int>& b){\n if(a[0] != b[0]){\n return a[0] < b[0];\n }\n return a[1] > b[1];\n}\nclass Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& ps) {\n int n = ps.size();\n sort(ps.begin(), ps.end(), cmp);\n int mx = ps[n...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
0
{ "code": "class Solution\n{\npublic:\n \n static bool comp(vector<int> &a, vector<int> &b)\n {\n if (a[0] == b[0])\n {\n return a[1] > b[1];\n }\n return a[0] < b[0];\n }\n int numberOfWeakCharacters(vector<vector<int>> &properties)\n {\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
0
{ "code": "class Solution {\npublic:\n static bool comp (const vector<int>& lhs, const vector<int>& rhs) {\n return (lhs[0] == rhs[0] && lhs[1] < rhs[1]) || lhs[0] > rhs[0];\n }\n \n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n sort(properties.begin(), properties.end(), co...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
1
{ "code": " class Solution\n{\npublic:\n //handling the edge case while sorting\n static bool comp(vector<int> &a, vector<int> &b)\n {\n if (a[0] == b[0])\n {\n return a[1] > b[1];\n }\n return a[0] < b[0];\n }\n int numberOfWeakCharacters(vecto...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
1
{ "code": "class Solution {\npublic:\n static bool comp (const vector<int>& lhs, const vector<int>& rhs) {\n return (lhs[0] == rhs[0] && lhs[1] < rhs[1]) || lhs[0] > rhs[0];\n }\n \n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n sort(properties.begin(), properties.end(), co...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n static bool cmp(vector<int>& a, vector<int>& b){\n if(a[0] < b[0]){\n return true;\n } else if(a[0] == b[0]){\n return a[1] > b[1];\n } else {\n return false;\n }\n }\n int numberOfWeakCharacters(vector<vector...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int n=properties.size(),max[100001];\n for (int i=0;i<100001;i++) max[i]=0;\n for (int i=0;i<n;i++) if (max[properties[i][0]]<properties[i][1]) max[properties[i][0]]=properties[i][1];\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "#include <algorithm>\n\nclass Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int n = properties.size();\n sort(properties.begin(), properties.end());\n\n stack <int> currentDefence;\n int mx = -1;\n int currentAttack = properties[...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& nums) {\n int ans = 0 ;\n sort(nums.begin(),nums.end(),[&](vector<int>&a,vector<int>&b){\n if(a[0] == b[0]){\n return a[1] > b[1] ;\n } \n return a[0] < b[0] ;\n });\n\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n// [6,3] ,[5,5],[3,6]\n static bool comp(vector<int> &v1, vector<int> &v2){\n if(v1[0] == v2[0]) return v1[1] < v2[1];\n return v1[0] > v2[0];\n }\n\n int numberOfWeakCharacters(vector<vector<int>>& nums) {\n sort(nums.begin(), nums.end(), comp);\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "#pragma GCC optimize (\"Ofast\")\n#pragma GCC target (\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx\")\n#pragma GCC optimize (\"-ffloat-store\")\n#pragma GCC optimize (\"O3\", \"unroll-loops\")\n\nclass Solution {\npublic:\n\n static bool comp(vector<int>&x,vector<int>&y){\n\n if(x[0]==y[0])return x[...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\nstatic bool comp(vector<int> &a,vector<int> &b){\n if(a[0] == b[0]){\n return a[1] > b[1];\n }\n return a[0] < b[0];\n}\n int numberOfWeakCharacters(vector<vector<int>>& p) {\n sort(p.begin(),p.end(), comp);\n stack<int> st;\n for(int i = ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n sort(properties.begin(), properties.end(), [&](const auto &x, const auto &y) {\n if(x[0] == y[0]) {\n return x[1] > y[1];\n }\n return x[0] < y[0];\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "bool cmp(vector<int>& a, vector<int>& b){\n if(a[0] != b[0]){\n return a[0] < b[0];\n }\n return a[1] > b[1];\n}\nclass Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& ps) {\n int n = ps.size();\n sort(ps.begin(), ps.end(), cmp);\n stack<int> st...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& nums) {\n sort(nums.begin(),nums.end());\n priority_queue<int,vector<int>,greater<int>>pq;\n int ans=0,i=0;\n stack<int>st;\n while(i<nums.size()){ \n if(i>0 && nums[i][0]==nums[i-1...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int maxAttack = 0;\n for (const auto& p : properties) {\n maxAttack = max(maxAttack, p[0]);\n }\n\n vector<int> maxDefense(maxAttack + 2, 0);\n for (const auto& p : p...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& nums) {\n sort(nums.begin(),nums.end());\n priority_queue<int,vector<int>,greater<int>>pq;\n int ans=0,i=0;\n stack<int>st;\n while(i<nums.size()){ \n if(i>0 && nums[i][0]==nums[i-1...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& nums) {\n sort(nums.begin(),nums.end());\n priority_queue<int,vector<int>,greater<int>>pq;\n int ans=0,i=0;\n stack<int>st;\n while(i<nums.size()){ \n if(i>0 && nums[i][0]==nums[i-1...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\n int searchAttack(vector<vector<int>>& arr,int i,int j,int attack){\n int ans=-1;\n while(i<=j){\n int mid=(i+j)/2; \n if(arr[mid][0] > attack){\n ans=mid;\n j=mid-1;\n }\n else{\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution \n{\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) \n {\n int n = properties.size();\n sort(properties.begin(), properties.end());\n vector<int> max_defence(n, 0);\n max_defence[n-1] = properties[n-1][1];\n\n for(int i=n-2;i>=0...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int ub(vector<vector<int>> &prop, int ele){\n int l = 0, r = prop.size() - 1;\n int ans = prop.size();\n while(l <= r){\n int mid = (l + r)/2;\n if(prop[mid][0] > ele){\n ans = mid;\n r = mid - 1;\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& p) {\n sort(p.begin(),p.end());\n int n = p.size();\n int ans =0;\n priority_queue< pair<int,int> , vector<pair<int,int>> , greater<pair<int,int>>> pq , pq1 , pq2;\n pq1.push({p[0][1],p[0][0]});\...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\nstatic bool cmp(vector<int>&a,vector<int>&b)\n{\n if(a[0]==b[0])return a[1]>b[1];\n return a[0]<b[0];\n}\n int numberOfWeakCharacters(vector<vector<int>>& p) {\n sort(p.begin(),p.end(),cmp);\n int cnt=0;\n stack<pair<int,int>> s;\n for(int i=0...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& p) {\n sort(p.begin(),p.end());\n int n = p.size();\n int ans =0;\n priority_queue< pair<int,int> , vector<pair<int,int>> , greater<pair<int,int>>> pq , pq1 , pq2;\n pq1.push({p[0][1],p[0][0]});\...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int n = properties.size();\n sort(properties.begin(), properties.end(),\n [](vector<int>& a, vector<int>& b) {\n if (a[0] == b[0]) {\n return a[1] > b...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n static bool cmp(vector<int>&v1,vector<int>&v2)\n {\n return v1[0]==v2[0]?v1[1]>v2[1]:v1[0]<v2[0];\n }\n int numberOfWeakCharacters(vector<vector<int>>& nums)\n {\n int count=0;\n int n=nums.size();\n sort(nums.begin(),nums.end(),cmp);\n...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
2
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n sort(properties.begin(), properties.end());\n int n = properties.size();\n int ans = 0;\n std::sort(\n properties.begin(), properties.end(),\n [](const std::vecto...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& nums) {\n sort(nums.begin(),nums.end());\n priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;\n int ans=0,i=0;\n stack<pair<int,int>>st;\n while(i<nums.size()){ \n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& nums) {\n sort(nums.begin(),nums.end());\n priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;\n int ans=0,i=0;\n stack<pair<int,int>>st;\n while(i<nums.size()){ \n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& nums) {\n sort(nums.begin(),nums.end());\n priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;\n int ans=0,i=0;\n stack<pair<int,int>>st;\n while(i<nums.size()){ \n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "#include <ranges>\nclass Solution {\n struct Character {\n int attack{}, defense{};\n };\npublic:\n int numberOfWeakCharacters(const std::vector<std::vector<int>>& properties) {\n std::vector<Character> characters{};\n characters.reserve(properties.size());\n for(const auto& vec : properties...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& p) {\n sort(p.begin(),p.end()); \n int n = p.size(); \n vector<int> right(n,-1);\n int maxi = -1;\n for(int i=n-1;i>=0;i--){\n \n maxi = max(maxi, p[i][1]);\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n \n int nex(vector<vector<int>>& properties, int i, vector<int>& nexi, vector<int>& maxi) {\n if(i!=0 && properties[i][0] == properties[i-1][0]){\n nexi[i] = nexi[i-1];\n return nexi[i];\n }\n int j=i;\n while(j<properties.size...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n if (properties.empty()) return 0;\n\n // Convert to pairs and sort the properties\n vector<pair<int, int>> p(properties.size());\n for (int i = 0; i < properties.size(); ++i) {\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n bool check(vector<int>& a, vector<int>& b){\n return (a[0] > b[0]) && (a[1] > b[1]);\n }\n int helper(int i, int prev, vector<vector<int>>& v){\n if(i == v.size()){return 0;}\n int taken = 0;\n int notTaken = helper(i+1, prev, v);\n if(prev ==...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\nstatic bool mycomp(vector<int>&v1,vector<int>&v2){\n if(v1[0]==v2[0])return v1[1]>v2[1];\n else return v1[0]<v2[0];\n}\n\n// void fun1(vector<int>&v,int st,int en,int &c,vector<int>&cnt){\n\n// int l=st,md=(st+en)/2,r=md+1,f=0;\n// vector<int>temp;\n// while(l<=...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& p) {\n vector<pair<int,int>> en(p.size());\n int n = p.size(); \n for(int i=0; i<n; i++){\n en[i] = {p[i][0], p[i][1]};\n }\n sort(en.begin(), en.end(), [](pair<int,int> a, pair<int,...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n static bool comp(pair<int, int> a, pair<int, int> b) {\n if (a.first == b.first)\n return a.second > b.second;\n return a.first < b.first;\n }\n\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int n = properties.size();\...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n\n static bool customComparison(pair<int,int> a, pair<int,int> b) \n { \n // Custom comparison logic \n if(a.first==b.first){\n return a.second<b.second;\n }\n \n return a.first>b.first;\n \n } \n int numberOfWeakCha...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n // sort on attack.\n // postmax defence. \n priority_queue<\n pair<int, int>, vector<pair<int, int>>, less<pair<int, int>>> heap;\n\n for(auto &vec : properties) {\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n \n bool static cmp(const pair<int,int> &a,const pair<int,int> &b){\n\n if(a.first == b.first){\n return (a.second > b.second);\n }\n\n else{\n return (a.first < b.first);\n }\n }\n\n int numberOfWeakCharacters(vector<...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties)\n {\n vector<pair<int,int>> arr;\n for (auto& p : properties)\n {\n arr.push_back(make_pair(p[0], p[1]));\n }\n \n std::sort(arr.begin(), arr.end());\n i...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n static bool comp(vector<int>&a, vector<int>&b)\n {\n if(a[0]==b[0])\n return a[1]>b[1];\n\n return a[0]<b[0];\n }\n int numberOfWeakCharacters(vector<vector<int>>& p) {\n sort(p.begin(), p.end(), comp);\n\n stack<int>st;\n\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n sort(properties.begin(), properties.end(),[&](const vector<int>&a, const vector<int>&b){\n return (a[0]==b[0])? (a[1]<b[1]) : a[0]>b[0];\n });\n int ans = 0, max_def = INT_MIN;\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n static bool compare(const vector<int>& a, const vector<int>& b){\n if(a[0]==b[0]) return a[1]<b[1];\n return a[0]>b[0];\n }\n\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int ans = 0;\n sort(properties.begin(), properties...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n static bool comp(vector<int> &a,vector<int> &b){\n if(a[0]!=b[0])\n return a[0]>b[0];\n return a[1]<b[1];\n }\n int numberOfWeakCharacters(vector<vector<int>>& prop) {\n sort(prop.begin(),prop.end(),comp);\n int maxTillNow = INT_MI...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n static bool comp(vector<int> &a,vector<int> &b){\n if(a[0]!=b[0])\n return a[0]>b[0];\n return a[1]<b[1];\n }\n int numberOfWeakCharacters(vector<vector<int>>& prop) {\n sort(prop.begin(),prop.end(),comp);\n int ma = INT_MIN;\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "int nums[100003];\nint A = [](){\n for(int i = 0; i < 100003; i++) nums[i] = 0;\n return 0;\n}();\nunordered_set<ushort> X;\nunordered_set<ushort> Y;\nvoid update(const int &idx, const int &updatev){\n if(nums[idx] < updatev) nums[idx] = updatev;\n if(idx < int(USHRT_MAX)) X.insert(idx); else Y...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "int nums[100003];\nint A = [](){\n for(int i = 0; i < 100003; i++) nums[i] = 0;\n return 0;\n}();\nunordered_set<ushort> X;\nunordered_set<ushort> Y;\nvoid update(const int &idx, const int &updatev){\n if(nums[idx] < updatev) nums[idx] = updatev;\n if(idx < USHRT_MAX) X.insert(idx); else Y.inse...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n static bool comp(vector<int>& a, vector<int>& b){\n if (a[0]!=b[0]) return a[0]<b[0];\n return a[1]>b[1];\n }\n int numberOfWeakCharacters(vector<vector<int>>& prop) {\n sort(prop.begin(), prop.end(), comp);\n vector<int> ans, v;\n for...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n static bool comp(vector<int>&a,vector<int>&b){\n if(a[0] == b[0]){\n return a[1] > b[1];\n }\n return a[0] < b[0];\n }\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n sort(properties.begin(),properties.end(),comp)...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int n = properties.size();\n sort(properties.begin(), properties.end(), [](vector<int>& a, vector<int>& b){\n if(a[0] == b[0]){\n return a[1] > b[1];\n }\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int n = properties.size();\n sort(properties.begin(), properties.end(), [](vector<int>& a, vector<int>& b){\n if(a[0] == b[0]){\n return a[1] > b[1];\n }\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int n = properties.size();\n sort(properties.begin(), properties.end(), [](vector<int>& a, vector<int>& b){\n if(a[0] == b[0]){\n return a[1] > b[1];\n }\n ...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n static bool mycomp(vector<int> &a, vector<int> &b){\n if(a[0] != b[0])\n return a[0] < b[0];\n return a[1] > b[1];\n }\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int n = properties.size();\n sort(properties.b...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n bool static cmp(pair<int,int>&a,pair<int,int>&b)\n {\n if(a.first==b.first)\n {\n return a.second>b.second;\n }\n return a.first<b.first;\n }\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n vector<pair<i...
2,123
<p>You are playing a game that contains multiple characters, and each of the characters has <strong>two</strong> main properties: <strong>attack</strong> and <strong>defense</strong>. You are given a 2D integer array <code>properties</code> where <code>properties[i] = [attack<sub>i</sub>, defense<sub>i</sub>]</code> re...
3
{ "code": "class Solution {\npublic:\n int numberOfWeakCharacters(vector<vector<int>>& properties) {\n int ans = 0;\n int N = properties.size();\n auto cmp = [](vector<int>& x, vector<int>& y){\n if (x[0] == y[0]) return x[1] > y[1];\n return x[0] < y[0];\n };\n ...