question_slug stringlengths 3 77 | title stringlengths 1 183 | slug stringlengths 12 45 | summary stringlengths 1 160 ⌀ | author stringlengths 2 30 | certification stringclasses 2
values | created_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | updated_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | hit_count int64 0 10.6M | has_video bool 2
classes | content stringlengths 4 576k | upvotes int64 0 11.5k | downvotes int64 0 358 | tags stringlengths 2 193 | comments int64 0 2.56k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
number-of-rectangles-that-can-form-the-largest-square | C++ easy solution | c-easy-solution-by-arvindxsharma-fodh | \nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n vector<int>arr;\n int temp=1;\n for(int i=0;i | arvindxsharma | NORMAL | 2022-07-30T17:38:50.498700+00:00 | 2022-07-30T17:38:50.498740+00:00 | 244 | false | ```\nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n vector<int>arr;\n int temp=1;\n for(int i=0;i<rectangles.size();i++){\n int length=rectangles[i][0];\n int breadth=rectangles[i][1];\n int ans=min(length,breadth);\n ... | 2 | 0 | ['Array', 'C'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | javascript solution | javascript-solution-by-webbyelena-ss7v | \nvar countGoodRectangles = function(rectangles) {\n let [min, max, count] = [0, 0, 0];\n \n for(let i = 0; i < rectangles.length; i++) {\n let | webbyelena | NORMAL | 2022-06-24T16:15:26.111668+00:00 | 2022-06-24T22:55:23.054669+00:00 | 148 | false | ```\nvar countGoodRectangles = function(rectangles) {\n let [min, max, count] = [0, 0, 0];\n \n for(let i = 0; i < rectangles.length; i++) {\n let rec = rectangles[i];\n min = foundMin(rec[0], rec[1]); \n if( min == max ) {\n count++;\n }\n if( min > max ) {... | 2 | 0 | ['JavaScript'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | [Java] Traversal Easy Approach | 1ms | 100% | java-traversal-easy-approach-1ms-100-by-blwfe | java []\nclass Solution {\n\tpublic int countGoodRectangles(int[][] rectangles) {\n\t\tint res = 0, max = -1;\n\t\tfor (int[] rect : rectangles) {\n\t\t\tint cu | ethanrao | NORMAL | 2022-02-04T00:46:33.126751+00:00 | 2022-10-16T08:59:49.155188+00:00 | 130 | false | ```java []\nclass Solution {\n\tpublic int countGoodRectangles(int[][] rectangles) {\n\t\tint res = 0, max = -1;\n\t\tfor (int[] rect : rectangles) {\n\t\t\tint cur = Math.min(rect[0], rect[1]);\n\t\t\tif (cur == max) {\n\t\t\t\tres++;\n\t\t\t} else if (cur > max) {\n\t\t\t\tmax = cur;\n\t\t\t\tres = 1;\n\t\t\t}\n\t\t}... | 2 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | [Python] O(n) time and O(1) space | python-on-time-and-o1-space-by-nttncs-0ngo | \ndef countGoodRectangles(self, rectangles):\n """\n :type rectangles: List[List[int]]\n :rtype: int\n """\n max_len = 0\n | nttncs | NORMAL | 2021-10-25T12:18:49.660981+00:00 | 2021-10-25T12:18:49.661010+00:00 | 73 | false | ```\ndef countGoodRectangles(self, rectangles):\n """\n :type rectangles: List[List[int]]\n :rtype: int\n """\n max_len = 0\n count_max = 0\n for l, w in rectangles:\n min_len = min(l, w)\n if min_len > max_len:\n max_len = min_len \n... | 2 | 0 | [] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Simple and Easy C++ Solution | simple-and-easy-c-solution-by-pranav_ahe-wfo1 | \nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n map <int, int> m;\n\n for (auto i : rectangles)\n | Pranav_Aher | NORMAL | 2021-07-29T04:21:54.120617+00:00 | 2021-07-29T04:21:54.120653+00:00 | 157 | false | ```\nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n map <int, int> m;\n\n for (auto i : rectangles)\n m[min(i[0], i[1])]++;\n\n return m.rbegin()->second;\n }\n};\n``` | 2 | 0 | ['C', 'C++'] | 1 |
number-of-rectangles-that-can-form-the-largest-square | JS O(N) solution | js-on-solution-by-makhmudgaly-pm0m | Please check out this solution\n\n/**\n * @param {number[][]} rectangles\n * @return {number}\n */\nvar countGoodRectangles = function(rectangles) {\n let ha | makhmudgaly | NORMAL | 2021-07-21T00:06:25.704117+00:00 | 2021-07-21T00:06:25.704150+00:00 | 89 | false | Please check out this solution\n```\n/**\n * @param {number[][]} rectangles\n * @return {number}\n */\nvar countGoodRectangles = function(rectangles) {\n let hash = {}\n let max = 0\n for(let [l,w] of rectangles) {\n let side = Math.min(l,w)\n max = Math.max(max, side)\n hash[side] = hash[... | 2 | 0 | ['JavaScript'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | C++ fast and Simple (You'll love it guaranteed.) | c-fast-and-simple-youll-love-it-guarante-zn2q | \nIf you have Learned something new please give it upvote;\notherwise thank you for having a look \uD83D\uDE4F\uD83C\uDFFB\n\nWe have to find out the minimum le | krishna_patil1 | NORMAL | 2021-06-22T10:52:50.866007+00:00 | 2021-06-22T10:52:50.866057+00:00 | 54 | false | \nIf you have Learned something new please give it upvote;\notherwise thank you for having a look \uD83D\uDE4F\uD83C\uDFFB\n\nWe have to find out the minimum length of rectangles.\nbcoz we have to cut out the remaining part of rectangle in order to make it a Square.\n\n```\nint countGoodRectangles(vector<vector<int>>& ... | 2 | 1 | [] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Python Faster than 96.52%. Easy to understand | python-faster-than-9652-easy-to-understa-5576 | \nclass Solution(object):\n def countGoodRectangles(self, rectangles):\n """\n :type rectangles: List[List[int]]\n :rtype: int``\n | user0791 | NORMAL | 2021-04-26T17:32:20.692287+00:00 | 2021-04-26T17:32:20.692334+00:00 | 90 | false | ```\nclass Solution(object):\n def countGoodRectangles(self, rectangles):\n """\n :type rectangles: List[List[int]]\n :rtype: int``\n """\n lst = [min(item) for item in rectangles]\n return lst.count(max(lst))\n``` | 2 | 0 | [] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Ruby: Map, max, count. | ruby-map-max-count-by-user9697n-y592 | Leetcode: 1725. Number Of Rectangles That Can Form The Largest Square.\n\nRuby: Map, max, count.\n\nMap array from array of pairs into array of pair minumums, f | user9697n | NORMAL | 2021-04-21T16:10:32.219431+00:00 | 2021-04-21T16:10:44.373625+00:00 | 37 | false | ## Leetcode: 1725. Number Of Rectangles That Can Form The Largest Square.\n\n**Ruby: Map, max, count.**\n\nMap array from array of pairs into array of pair minumums, find maximum value of this array, count number of maximum value matches. That\'s it.\n\n\nRuby code:\n```Ruby\n# Leetcode: 1725. Number Of Rectangles That... | 2 | 0 | ['Ruby'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Java simple O(n) solution > 100% | java-simple-on-solution-100-by-titasdatt-f1v3 | \n\nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int largestSide = Integer.MIN_VALUE;\n int countLargest = 0;\n | titasdatta93 | NORMAL | 2021-04-10T12:35:28.411570+00:00 | 2021-04-10T12:35:28.411614+00:00 | 75 | false | ```\n\nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int largestSide = Integer.MIN_VALUE;\n int countLargest = 0;\n \n for(int[] rect: rectangles) {\n int localMinSide = Math.min(rect[0], rect[1]); //Find the largest square that can be created from t... | 2 | 0 | [] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Python - Easy to understand | python-easy-to-understand-by-sbaisden25-bu64 | \n\nclass Solution:\n def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n \n #Runtime: 184 ms, faster than 65.71% of Python3 onli | sbaisden25 | NORMAL | 2021-04-07T16:09:49.134908+00:00 | 2021-04-07T17:17:33.606845+00:00 | 202 | false | ```\n\nclass Solution:\n def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n \n #Runtime: 184 ms, faster than 65.71% of Python3 online submissions\n #Memory Usage: 14.9 MB, less than 39.90% of Python3 online submissions\n \n res = []\n \n minSide = 0\n ... | 2 | 0 | ['Python'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Java Accepted Runtime:O(n) and Space:O(n) | java-accepted-runtimeon-and-spaceon-by-m-c9mh | \nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n \n int[] sq=new int[rectangles.length];\n int max=Integer.MI | manasviiiii | NORMAL | 2021-03-18T07:55:06.464724+00:00 | 2021-03-18T07:55:06.464770+00:00 | 87 | false | ```\nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n \n int[] sq=new int[rectangles.length];\n int max=Integer.MIN_VALUE; //will stores maxLen\n for(int i=0;i<rectangles.length;i++)\n {\n sq[i]=Math.min(rectangles[i][0],rectangles[i][1]);\n ... | 2 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | [GO] ~20ms | 98% faster | go-20ms-98-faster-by-coty91-oiei | \nfunc countGoodRectangles(rectangles [][]int) int {\n ml := 0 \n tml := 0\n \n for _, v := range rectangles {\n l := 0\n if v[0] > v[ | coty91 | NORMAL | 2021-02-11T01:16:25.473784+00:00 | 2021-02-11T01:16:25.473828+00:00 | 100 | false | ```\nfunc countGoodRectangles(rectangles [][]int) int {\n ml := 0 \n tml := 0\n \n for _, v := range rectangles {\n l := 0\n if v[0] > v[1] {\n l = v[1]\n } else {\n l = v[0]\n }\n if l > ml {\n ml = l\n tml = 1\n } else i... | 2 | 0 | ['Go'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Python One pass | python-one-pass-by-leovam-28hh | py\n\'\'\'\nw: hashmap + greedy\nh: count the frequency of each maxLen for each rectangle\n in the meanwhile, record the largest maxLex so far\n then at t | leovam | NORMAL | 2021-01-25T05:01:21.008396+00:00 | 2021-01-25T05:01:21.008455+00:00 | 196 | false | ```py\n\'\'\'\nw: hashmap + greedy\nh: count the frequency of each maxLen for each rectangle\n in the meanwhile, record the largest maxLex so far\n then at the end, just return the frequency of the largest maxLen\n\'\'\'\nimport collections\nclass Solution:\n def countGoodRectangles(self, rectangles: List[List... | 2 | 0 | ['Greedy', 'Python'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Java O(N) 3ms with easy to understand | java-on-3ms-with-easy-to-understand-by-a-iefx | Very easy question. Just follow what is being said.\n\n\nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int maxLen = 0;\n | ankitrathore | NORMAL | 2021-01-17T06:33:39.465432+00:00 | 2021-01-17T06:33:39.465458+00:00 | 150 | false | Very easy question. Just follow what is being said.\n\n```\nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int maxLen = 0;\n int count = 0;\n for(int i=0;i<rectangles.length;i++){\n int len = Math.min(rectangles[i][0], rectangles[i][1]);\n if(len ... | 2 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | javascript three lines 124ms | javascript-three-lines-124ms-by-henryche-cf9o | \nconst countGoodRectangles = (rectangles) => {\n let res = rectangles.map(x => Math.min(x[0], x[1]));\n let max = Math.max.apply(Math, res);\n return | henrychen222 | NORMAL | 2021-01-17T04:32:14.255005+00:00 | 2021-01-17T04:32:14.255032+00:00 | 186 | false | ```\nconst countGoodRectangles = (rectangles) => {\n let res = rectangles.map(x => Math.min(x[0], x[1]));\n let max = Math.max.apply(Math, res);\n return res.filter(x => x == max).length;\n};\n``` | 2 | 0 | ['JavaScript'] | 1 |
number-of-rectangles-that-can-form-the-largest-square | Hashmap C++ | hashmap-c-by-ishankochar-3sed | \nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& r) {\n unordered_map<int,int>mp;\n for(int i=0;i<r.size();i++){\n | ishankochar | NORMAL | 2021-01-17T04:01:50.489094+00:00 | 2021-01-17T04:01:50.489124+00:00 | 225 | false | ```\nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& r) {\n unordered_map<int,int>mp;\n for(int i=0;i<r.size();i++){\n if(r[i][0]<r[i][1]){\n mp[r[i][0]]++;\n }else{\n mp[r[i][1]]++;\n }\n }\n int m=IN... | 2 | 0 | [] | 0 |
number-of-rectangles-that-can-form-the-largest-square | ⭐️ [ Kt, Js, Py3, Cpp ] 🎯 Best == Max of Min(length, width) | kt-js-py3-cpp-best-max-of-minlength-widt-jcdg | \n Synopsis:\n\n1. Find the best square length as the maximum of the minimum of each rectangle\'s length l and width w\n2. Return the count of rectangles with | claytonjwong | NORMAL | 2021-01-17T04:01:43.704886+00:00 | 2021-01-17T04:05:17.058481+00:00 | 162 | false | \n **Synopsis:**\n\n1. Find the `best` square length as the maximum of the minimum of each rectangle\'s length `l` and width `w`\n2. Return the count of rectangles with length `l` and width `w` greater-than `best`\n\n---\n\n*Kotlin*\n```\nclass Solution {\n fun countGoodRectangles(A: Array<IntArray>): Int {\n ... | 2 | 0 | [] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Simple solution with O(n) time complexity ... | simple-solution-with-on-time-complexity-hru5u | IntuitionWe should take the smallest side from each rectangle and maximum from these numbers. And if there are many this kind of numbers we should count them .. | Shohruh11 | NORMAL | 2025-03-05T15:59:08.158675+00:00 | 2025-03-05T16:15:42.843307+00:00 | 89 | false | # Intuition
We should take the smallest side from each rectangle and maximum from these numbers. And if there are many this kind of numbers we should count them ...
# Approach
In for loop I took minimum side of each rectangle and checked weather it's the max and if it's the second max I incremented my count ...
# Com... | 1 | 0 | ['C++', 'Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Best Solution | C++ | best-solution-c-by-nssvaishnavi-7h6w | IntuitionTo solve this problem, we need to determine the largest possible square side length (maxLen) that can be cut from any of the given rectangles and then | nssvaishnavi | NORMAL | 2025-02-06T18:17:20.084384+00:00 | 2025-02-06T18:17:20.084384+00:00 | 38 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
To solve this problem, we need to determine the largest possible square side length (maxLen) that can be cut from any of the given rectangles and then count how many rectangles can form a square of that size.
# Approach
<!-- Describe your ... | 1 | 0 | ['C++'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Easy Solution in C | easy-solution-in-c-by-sathurnithy-jefs | Code | Sathurnithy | NORMAL | 2025-01-25T13:05:22.452087+00:00 | 2025-01-25T13:05:22.452087+00:00 | 27 | false | # Code
```c []
int countGoodRectangles(int** rectangles, int rectanglesSize, int* rectanglesColSize){
int max = INT_MIN;
int count = 0;
for(int i=0; i<rectanglesSize; i++){
int temp = (rectangles[i][0] > rectangles[i][1]) ? rectangles[i][1] : rectangles[i][0];
if(temp > max){
max... | 1 | 0 | ['Array', 'C'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Solution in C | solution-in-c-by-vickyy234-e8dq | Code | vickyy234 | NORMAL | 2025-01-24T17:12:17.190645+00:00 | 2025-01-24T17:12:57.453649+00:00 | 19 | false | # Code
```c []
int countGoodRectangles(int** rectangles, int rectanglesSize, int* rectanglesColSize) {
int max = 0;
int* arr = malloc(sizeof(int) * rectanglesSize);
for (int i = 0; i < rectanglesSize; i++) {
if (rectangles[i][0] < rectangles[i][1])
arr[i] = rectangles[i][0];
els... | 1 | 0 | ['Array', 'C', 'Counting'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Kotlin solution (beats 100% of users in time and space complexity) | kotlin-solution-beats-100-of-users-in-ti-02uy | Complexity
Time complexity: O(n)
Space complexity: O(n)
Code | Nihad04 | NORMAL | 2025-01-09T12:09:40.983664+00:00 | 2025-01-09T12:09:40.983664+00:00 | 11 | false | # Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```kotlin []
class Solution {
fun countGoodRectangles(rectangles: Array<IntArray>): Int {
val squareLengths = IntArray(rectangle... | 1 | 0 | ['Kotlin'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Java | O(n) | Easy solution ✅ | java-on-easy-solution-by-vaibhav_parmar7-ox0j | Approach\n Easy Approach\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n\nclass Solution {\n public int countGoodRectangles | vaibhav_parmar72 | NORMAL | 2024-08-07T10:18:08.694625+00:00 | 2024-08-07T10:18:08.694653+00:00 | 13 | false | # Approach\n Easy Approach\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n```\nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int[] temp = new int[rectangles.length];\n int max = Integer.MIN_VALUE;\n int res = 0;\n for(int i=0; ... | 1 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Python is Beautiful | python-is-beautiful-by-giorgizazadze-sth8 | Complexity\n- Time complexity: O(N)\n\n\n# Code\n\nclass Solution:\n def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n m = [min(n[0 | giorgizazadze | NORMAL | 2024-07-19T21:32:33.744394+00:00 | 2024-07-19T21:32:33.744439+00:00 | 64 | false | # Complexity\n- Time complexity: O(N)\n\n\n# Code\n```\nclass Solution:\n def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n m = [min(n[0], n[1])**2 for n in rectangles]\n return m.count(max(m))\n``` | 1 | 0 | ['Python3'] | 1 |
number-of-rectangles-that-can-form-the-largest-square | Easy method in python | easy-method-in-python-by-arun_balakrishn-jufx | \n\nclass Solution:\n def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n ans = 0\n count = 0\n for i in rectangles:\n | arun_balakrishnan | NORMAL | 2024-02-10T17:17:58.734153+00:00 | 2024-02-10T17:17:58.734175+00:00 | 45 | false | \n```\nclass Solution:\n def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n ans = 0\n count = 0\n for i in rectangles:\n temp = min(i)\n if temp > ans:\n ans = temp\n count = 1\n elif temp == ans:\n c... | 1 | 0 | ['Python3'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Beats 94.06% of users with Python in python || 126 ms | beats-9406-of-users-with-python-in-pytho-cxfv | Code\n\nclass Solution(object):\n def countGoodRectangles(self, rectangles):\n """\n :type rectangles: List[List[int]]\n :rtype: int\n | aditikprof | NORMAL | 2024-01-31T12:18:27.029226+00:00 | 2024-01-31T12:18:27.029254+00:00 | 9 | false | # Code\n```\nclass Solution(object):\n def countGoodRectangles(self, rectangles):\n """\n :type rectangles: List[List[int]]\n :rtype: int\n """\n max_length = max(min(rec) for rec in rectangles)\n count = sum(1 for rec in rectangles if min(rec) == max_length)\n return... | 1 | 0 | ['Python'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | ✅ C++ | Easy Code | Map | O(N) | c-easy-code-map-on-by-jagdish9903-obc8 | Complexity\n- Time complexity: O(N)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(N)\n Add your space complexity here, e.g. O(n) \n\n# Co | Jagdish9903 | NORMAL | 2024-01-21T13:29:03.327254+00:00 | 2024-01-21T13:29:03.327280+00:00 | 7 | false | # Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n int ans = 0;\n unorde... | 1 | 0 | ['Array', 'Ordered Map', 'C++'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Simple java code 0 ms beats 100 % | simple-java-code-0-ms-beats-100-by-arobh-3uar | \n# Complexity\n- \n\n# Code\n\nclass Solution {\n int count=0;\n public void result(int[][] matrix,int i,int max){\n if(i==matrix.length){\n | Arobh | NORMAL | 2024-01-15T12:29:31.355608+00:00 | 2024-01-15T12:29:31.355642+00:00 | 8 | false | \n# Complexity\n- \n\n# Code\n```\nclass Solution {\n int count=0;\n public void result(int[][] matrix,int i,int max){\n if(i==matrix.length){\n return ;\n }\n int temp... | 1 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | c++(simple solution) | csimple-solution-by-barsha_511-d3b7 | \n# Approach\n Describe your approach to solving the problem. \n\nInitialization:\n\nInitialize a vector v to store the minimum side lengths of each rectangle.\ | Barsha_511 | NORMAL | 2024-01-04T11:44:46.107595+00:00 | 2024-01-04T11:44:46.107626+00:00 | 120 | false | \n# Approach\n<!-- Describe your approach to solving the problem. -->\n\nInitialization:\n\nInitialize a vector v to store the minimum side lengths of each rectangle.\nInitialize variables minv to keep track of the minimum side length for each rectangle, maxx to store the count of rectangles with the maximum side lengt... | 1 | 0 | ['C++'] | 1 |
number-of-rectangles-that-can-form-the-largest-square | Easy solution in Python3 that beats 99.12% users | easy-solution-in-python3-that-beats-9912-2dfv | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | naikadesahil2840 | NORMAL | 2023-12-27T16:34:33.480536+00:00 | 2023-12-27T16:34:33.480570+00:00 | 24 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Python3'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Simple solution with HashMap in Python3 | simple-solution-with-hashmap-in-python3-jw1gx | Intuition\nHere we have:\n- list of rectangles with height and width\n- our goal is to find maximized count of rects we can cut, to have a perfect square \n\nAt | subscriber6436 | NORMAL | 2023-11-20T08:53:39.194854+00:00 | 2023-11-20T08:55:04.151665+00:00 | 379 | false | # Intuition\nHere we have:\n- list of `rectangles` with height and width\n- our goal is to find **maximized count** of rects **we can cut**, to have a **perfect square** \n\nAt each step we should somehow **cut** all of the rects to find a `maxLen`.\n\nFor this problem we\'re going to use **HashMap** to track **frequen... | 1 | 0 | ['Array', 'Hash Table', 'Python3'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | One line python3 solution | one-line-python3-solution-by-fobos_hero-7lz4 | Approach\nFunction counts how many rectangles have both sides equal to the maximum of the minimum values (length and width) of each rectangle using the sum met | fobos_hero | NORMAL | 2023-09-25T13:24:32.000640+00:00 | 2023-09-25T13:24:32.000673+00:00 | 9 | false | # Approach\nFunction counts how many rectangles have both sides equal to the maximum of the minimum values (length and width) of each rectangle using the sum method of the rectangles list\n\n\n# Complexity\n- Time complexity: O(1)\n\n- Space complexity: O(n)\n\n# Code\n```\nclass Solution:\n def countGoodRectangles... | 1 | 0 | ['Python3'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | easy understanding JAVA code | easy-understanding-java-code-by-maddy_mr-i6r3 | Intuition\n Describe your first thoughts on how to solve this problem. \nnew array of min integers, find max in that array with count;\n# Approach\n Describe yo | maddy_MR | NORMAL | 2023-09-17T12:05:09.359513+00:00 | 2023-09-17T12:05:09.359530+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nnew array of min integers, find max in that array with count;\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space compl... | 1 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Beats 68.09%of users with Python😁 and Beats 77.66%of users with Python😁 6.8 and 7.7 balance | beats-6809of-users-with-python-and-beats-plmd | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Hushigiro | NORMAL | 2023-08-29T07:23:37.426306+00:00 | 2023-08-29T07:23:37.426342+00:00 | 106 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Python'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | With basic of python code | with-basic-of-python-code-by-paulsoumyad-ge04 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | paulsoumyadeep7 | NORMAL | 2023-08-18T04:34:04.853413+00:00 | 2023-08-18T04:34:04.853431+00:00 | 178 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Python3'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | python3 highly efficient solution using a very different approach beats 98% | python3-highly-efficient-solution-using-twzzb | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | ResilientWarrior | NORMAL | 2023-08-13T07:48:31.589555+00:00 | 2023-08-13T07:48:31.589579+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Python3'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Simple Solution | simple-solution-by-suchitaupatil-kv89 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | suchitaupatil | NORMAL | 2023-07-20T04:51:31.196200+00:00 | 2023-07-20T04:51:31.196218+00:00 | 531 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['C++'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Number Of Rectangles That Can Form The Largest Square Solution in C++ | number-of-rectangles-that-can-form-the-l-4bn5 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | The_Kunal_Singh | NORMAL | 2023-03-04T05:39:15.918579+00:00 | 2023-03-04T05:39:15.918630+00:00 | 20 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$... | 1 | 0 | ['C++'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Kotlin solution | kotlin-solution-by-xemura-3uy2 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | xemura | NORMAL | 2023-02-14T13:16:52.174580+00:00 | 2023-02-14T13:16:52.174627+00:00 | 160 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Kotlin'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | java || Beats 100% | java-beats-100-by-md_aziz_ali-f6a4 | \nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int max = 0,len = 0;\n for(int i = 0;i<rectangles.length;i++){\n | Md_Aziz_Ali | NORMAL | 2023-01-27T12:34:10.131669+00:00 | 2023-01-27T12:34:10.131720+00:00 | 23 | false | ```\nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int max = 0,len = 0;\n for(int i = 0;i<rectangles.length;i++){\n int side = Math.min(rectangles[i][0],rectangles[i][1]);\n if(side > len){\n len = side;\n max = 1;\n ... | 1 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | easy to understand || 0ms || accepted solution | easy-to-understand-0ms-accepted-solution-296p | Intuition\nwe need to first find minima of each sub-array and then find maxima of all the minimas and then check how many times that maxima is occuring in the | Chetali1 | NORMAL | 2023-01-02T08:03:49.365962+00:00 | 2023-01-02T08:03:49.366003+00:00 | 20 | false | # Intuition\nwe need to first find minima of each sub-array and then find maxima of all the minimas and then check how many times that maxima is occuring in the array of minimas.\n# Approach\nwe first iterate through the array rectangles and find minima of each sub-array and store them in a new array mins. then find t... | 1 | 0 | ['Array', 'Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | JAVA Simple Solution - 3ms beats 81% | java-simple-solution-3ms-beats-81-by-smr-vmth | \nclass Solution {\n public int countGoodRectangles(int[][] arr) {\n int[] sq = new int[arr.length];\n int m=arr.length;\n int n=arr[0]. | SmritiGangwar | NORMAL | 2022-12-01T19:34:56.990978+00:00 | 2022-12-01T19:36:43.941891+00:00 | 710 | false | ```\nclass Solution {\n public int countGoodRectangles(int[][] arr) {\n int[] sq = new int[arr.length];\n int m=arr.length;\n int n=arr[0].length;\n for(int i=0;i<m;i++){\n if(arr[i][0]<arr[i][1]){\n sq[i]=arr[i][0];\n }\n else{\n ... | 1 | 0 | [] | 0 |
number-of-rectangles-that-can-form-the-largest-square | JAVA Simple Solution - 3ms beats 81.4% | java-simple-solution-3ms-beats-814-by-it-qr18 | \n\n# Code\n\nclass Solution {\n public int countGoodRectangles(int[][] arr) {\n int[] sq = new int[arr.length];\n int m=arr.length;\n i | Its_Smriti | NORMAL | 2022-12-01T18:00:58.540502+00:00 | 2022-12-10T07:13:47.402144+00:00 | 1,124 | false | \n\n# Code\n```\nclass Solution {\n public int countGoodRectangles(int[][] arr) {\n int[] sq = new int[arr.length];\n int m=arr.length;\n int n=arr[0].length;\n for(int i=0;i<m;i++){\n if(arr[i][0]<arr[i][1]){\n sq[i]=arr[i][0];\n }\n else{\... | 1 | 0 | ['Array', 'Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Python | easy solution | python-easy-solution-by-arshia_ilaty-j0ht | Please upvote if you like my solution. Let me know in the comments if you have any suggestions to increase performance or readability.\n\nclass Solution:\n d | arshia_ilaty | NORMAL | 2022-11-19T18:33:35.857830+00:00 | 2022-11-19T18:33:35.857879+00:00 | 58 | false | **Please upvote if you like my solution. Let me know in the comments if you have any suggestions to increase performance or readability.**\n```\nclass Solution:\n def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n large = []\n t = 0\n for rec in rectangles:\n mi = mi... | 1 | 0 | ['Python'] | 1 |
number-of-rectangles-that-can-form-the-largest-square | easy solution || Python | easy-solution-python-by-maary-662g | \n\n# Code\n\nclass Solution:\n def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n squares=[min(i) for i in rectangles]\n ret | maary_ | NORMAL | 2022-10-16T01:02:53.001293+00:00 | 2022-10-16T01:02:53.001337+00:00 | 200 | false | \n\n# Code\n```\nclass Solution:\n def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n squares=[min(i) for i in rectangles]\n return squares.count(max(squares))\n``` | 1 | 0 | ['Python3'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Java | O(n) | Easy solution ✅ | java-on-easy-solution-by-geethub17-4anr | \npublic int countGoodRectangles(int[][] rectangles) {\n\t\tint min, max = 0, previousMax=0, highesht = 0;\n\t\tfor (int j[] : rectangles) {\n\t\t\tmin = Math.m | geethub17 | NORMAL | 2022-10-08T17:22:39.894282+00:00 | 2022-10-08T17:26:39.272087+00:00 | 180 | false | ```\npublic int countGoodRectangles(int[][] rectangles) {\n\t\tint min, max = 0, previousMax=0, highesht = 0;\n\t\tfor (int j[] : rectangles) {\n\t\t\tmin = Math.min(j[0], j[1]); \n\t\t\tpreviousMax = max;\n\t\t\tmax = Math.max(max, min);\n\t\t\thighesht = (max == min && previousMax == max) ? highesht + 1 : (previousMa... | 1 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | c++ | easy | step by step | c-easy-step-by-step-by-venomhighs7-gnze | \n# Code\n\nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n unordered_map<int,int> map;\n for(vector<i | venomhighs7 | NORMAL | 2022-10-01T04:50:17.077821+00:00 | 2022-10-01T04:50:17.077867+00:00 | 775 | false | \n# Code\n```\nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n unordered_map<int,int> map;\n for(vector<int> rectangle: rectangles){\n map[min(rectangle[0],rectangle[1])]++;\n }\n int cnt=INT_MIN,maxlen=INT_MIN;\n for(auto m: map)... | 1 | 0 | ['C++'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Java easy very easy solution, single loop and just if else condition.. | java-easy-very-easy-solution-single-loop-rp1a | \nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int max=0;\n int count=0;\n for(int i=0;i<rectangles.length;i++ | MukulAlmora | NORMAL | 2022-09-08T21:12:03.345869+00:00 | 2022-09-08T21:12:03.345963+00:00 | 555 | false | ```\nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int max=0;\n int count=0;\n for(int i=0;i<rectangles.length;i++){\n int min=Math.min(rectangles[i][0],rectangles[i][1]); \n if(max<min){\n max=min;\n count=1;\n ... | 1 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | JAVA -1ms | java-1ms-by-rupa_02-xfc8 | class Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int max=Integer.MIN_VALUE,c=0;\n for(int i=0;i<rectangles.length;i++) | rupa_02 | NORMAL | 2022-09-04T05:08:13.620330+00:00 | 2022-09-04T05:08:13.620377+00:00 | 27 | false | class Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int max=Integer.MIN_VALUE,c=0;\n for(int i=0;i<rectangles.length;i++){\n int nmax=Math.min(rectangles[i][0],rectangles[i][1]);\n if(max<nmax){\n max=nmax;\n c=1;\n } ... | 1 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | ✅✅Easy C++ Solution || Simple to Understand | easy-c-solution-simple-to-understand-by-6qalt | \tclass Solution {\n\tpublic:\n\t\tint countGoodRectangles(vector>& rectangles) {\n\n\t\t\tint n = rectangles.size();\n\t\t\tvector v;\n\n\t\t\tfor(int i=0 ; i< | debav2 | NORMAL | 2022-08-11T20:05:09.786788+00:00 | 2022-08-11T20:05:22.447624+00:00 | 161 | false | \tclass Solution {\n\tpublic:\n\t\tint countGoodRectangles(vector<vector<int>>& rectangles) {\n\n\t\t\tint n = rectangles.size();\n\t\t\tvector<int> v;\n\n\t\t\tfor(int i=0 ; i<n ; i++){ \n\t\t\t\tv.push_back(min(rectangles[i][0], rectangles[i][1]));\n\t\t\t}\n\n\t\t\tint maxLen = *max_element(v.begin(), v.end());\n... | 1 | 0 | ['C', 'C++'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | [GO] Two Solutions Faster than 90%| | SPEED: 23 ms || MEMORY: 6.5 mb | | go-two-solutions-faster-than-90-speed-23-96lw | Hey,mate! This is my quick solution\n# \nFIRST \n\n\tfunc countGoodRectangles(rectangles [][]int) int {\n\t\tarray := make(map[int]int,0)\n\t\tfor ,rectangle := | blessingman | NORMAL | 2022-08-06T15:01:12.643312+00:00 | 2022-08-06T15:05:40.586038+00:00 | 90 | false | # Hey,mate! This is my quick solution\n# \nFIRST \n\n\tfunc countGoodRectangles(rectangles [][]int) int {\n\t\tarray := make(map[int]int,0)\n\t\tfor _,rectangle := range rectangles {\n\t\t\tk := rectangle[0]\n\t\t\tif k > rectangle[1]{\n\t\t\t k = rectangle[1]\n\t\t\t}\n\t\t\tarray[k]++\n\t\t}\n\t\tmax :=0 \n\t\tfor ... | 1 | 0 | ['Go'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Easy Optimise Solution | easy-optimise-solution-by-sanket_jadhav-n9p1 | ```\nclass Solution {\npublic:\n int countGoodRectangles(vector>& rectangles) {\n int side=INT_MIN,ct=0;\n \n for(auto ele:rectangles){\ | Sanket_Jadhav | NORMAL | 2022-08-06T04:57:26.780054+00:00 | 2022-08-06T04:57:26.780102+00:00 | 78 | false | ```\nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n int side=INT_MIN,ct=0;\n \n for(auto ele:rectangles){\n side=max(side,(min(ele[0],ele[1])));\n }\n \n for(auto ele:rectangles){\n if(min(ele[0],ele[1])==side)c... | 1 | 0 | ['Array', 'C++'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | C++ : Easy Solution | c-easy-solution-by-beast_paw-h5eh | \nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n int ans=0,mn=0;\n for(int i=0;i<rectangles.size();i+ | beast_paw | NORMAL | 2022-07-21T09:31:44.950832+00:00 | 2022-07-21T09:31:44.950883+00:00 | 42 | false | ```\nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n int ans=0,mn=0;\n for(int i=0;i<rectangles.size();i++)\n mn=max(mn,min(rectangles[i][0],rectangles[i][1]));\n for(int i=0;i<rectangles.size();i++)\n if(rectangles[i][0]>=mn&&rectan... | 1 | 0 | ['C'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Number of rectangles that can form the largest square - C solution | number-of-rectangles-that-can-form-the-l-i1g0 | \n\n\nint countGoodRectangles(int** rectangles, int rectanglesSize, int* rectanglesColSize){\n int i,j=0,maxlength=0,count=0;\n int * a = malloc( rectangl | himanshiiarora | NORMAL | 2022-07-19T09:05:41.461854+00:00 | 2022-07-19T09:06:36.357232+00:00 | 23 | false | ```\n\n\nint countGoodRectangles(int** rectangles, int rectanglesSize, int* rectanglesColSize){\n int i,j=0,maxlength=0,count=0;\n int * a = malloc( rectanglesSize * sizeof(int));\n for(i=0;i<rectanglesSize;i++){\n if(rectangles[i][j] <= rectangles[i][j+1]){\n maxlength = rectangles[i][j];\n ... | 1 | 0 | ['Array'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Simple Java Solution | Brute Force | simple-java-solution-brute-force-by-aman-tiue | \nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n\t\n int[] k = new int[rectangles.length];\n\t\t\n for(int i = 0; i | amankesarwani34 | NORMAL | 2022-07-19T08:21:59.005601+00:00 | 2022-07-19T08:22:50.662789+00:00 | 55 | false | ```\nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n\t\n int[] k = new int[rectangles.length];\n\t\t\n for(int i = 0; i < rectangles.length; i++){\n int minSideLength = rectangles[i][0];\n for(int j = 0; j < rectangles[i].length; j++){\t\n ... | 1 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Basic Approach (From Youtube) C++ | basic-approach-from-youtube-c-by-sagarke-8jvb | \nclass Solution {\npublic:\n \n \n int countGoodRectangles(vector<vector<int>>& rectangles) {\n int maxlen=0,maxwid=0,count=0;\nfor(int i=0;i<rectangle | sagarkesharwnnni | NORMAL | 2022-07-18T19:45:55.995176+00:00 | 2022-07-18T19:45:55.995209+00:00 | 28 | false | ```\nclass Solution {\npublic:\n \n \n int countGoodRectangles(vector<vector<int>>& rectangles) {\n int maxlen=0,maxwid=0,count=0;\nfor(int i=0;i<rectangles.size();i++)\n{\nmaxwid= min(rectangles[i][0],rectangles[i][1]);\nif(maxwid>maxlen)\n{\nmaxlen=maxwid;\ncount=0;\n}\nif(maxlen==maxwid)\n{\ncount++;\n}\n}\n... | 1 | 0 | [] | 0 |
number-of-rectangles-that-can-form-the-largest-square | ✅C++ || Simple && Straightforward || EASY | c-simple-straightforward-easy-by-abhinav-hv4o | \n\nn==r.size()\nT->O(n) && S->O(1)\n\n\tclass Solution {\n\tpublic:\n\t\tint countGoodRectangles(vector>& r) {\n\t\t\tint m=INT_MIN,count=0;\n\t\t\tfor(int i=0 | abhinav_0107 | NORMAL | 2022-07-08T19:34:21.149429+00:00 | 2022-07-08T19:34:21.149478+00:00 | 89 | false | \n\n**n==r.size()\nT->O(n) && S->O(1)**\n\n\tclass Solution {\n\tpublic:\n\t\tint countGoodRectangles(vector<vector<int>>& r) {\n\t\t\tint m=INT_MIN,count=0;\n\t\t\tfor(int i=0;i<r.size();i++) m=max(min(r[i][0]... | 1 | 0 | ['C', 'C++'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | 📌Fastest & Easy Java☕ solution using hashmap | fastest-easy-java-solution-using-hashmap-to1d | ```\nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n HashMap hmap = new HashMap<>();\n int k=0;\n for(int rect | saurabh_173 | NORMAL | 2022-07-08T10:08:21.840999+00:00 | 2022-07-08T10:08:21.841036+00:00 | 52 | false | ```\nclass Solution {\n public int countGoodRectangles(int[][] rectangles) {\n HashMap<Integer,Integer> hmap = new HashMap<>();\n int k=0;\n for(int rectangle[]:rectangles)\n {\n int min = Math.min(rectangle[0],rectangle[1]);\n if(min>=k)\n {\n ... | 1 | 0 | ['Java'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Simple C++ Solution TC: O(N) SC: O(1) | simple-c-solution-tc-on-sc-o1-by-lawliet-th7q | \nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n \n int max = 0, count = 0;\n \n //Loop | lawliet007 | NORMAL | 2022-06-18T18:18:22.000388+00:00 | 2022-06-18T18:18:29.450438+00:00 | 50 | false | ```\nclass Solution {\npublic:\n int countGoodRectangles(vector<vector<int>>& rectangles) {\n \n int max = 0, count = 0;\n \n //Loop through each of the rectangles\n for(vector side: rectangles) {\n //find the minimum size of rectangle\n int s = side[0] < side... | 1 | 0 | [] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Javascript solution :) | javascript-solution-by-milosdjurica-drjt | In first loop MaxLen is found.\nIn second loop counting number of MaxLen rectangles.\n\n\n\n/*\n * @param {number[][]} rectangles\n * @return {number}\n */\nvar | milosdjurica | NORMAL | 2022-06-16T23:24:48.225896+00:00 | 2022-06-16T23:24:48.225936+00:00 | 143 | false | In first loop MaxLen is found.\nIn second loop counting number of MaxLen rectangles.\n\n```\n\n/*\n * @param {number[][]} rectangles\n * @return {number}\n */\nvar countGoodRectangles = function (rectangles) {\n let max = 0\n for (let i = 0; i < rectangles.length; i++) {\n rectangles[i][0] < rectangles[i][... | 1 | 0 | ['JavaScript'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Java Solution Without map O(1) space linear time | java-solution-without-map-o1-space-linea-a7tf | class Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int countRec=0;\n int maxLen=0;\n for(int i[]:rectangles){\n | draculatapes | NORMAL | 2022-06-03T16:39:44.203054+00:00 | 2022-06-03T16:41:10.471155+00:00 | 42 | false | class Solution {\n public int countGoodRectangles(int[][] rectangles) {\n int countRec=0;\n int maxLen=0;\n for(int i[]:rectangles){\n int length=i[0];\n int width=i[1];\n int currMaxLen=Math.min(length,width);\n if(currMaxLen>maxLen){\n m... | 1 | 0 | [] | 0 |
number-of-rectangles-that-can-form-the-largest-square | faster than 99.01%| Python Easy Solution | faster-than-9901-python-easy-solution-by-2znw | def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n maxlenL=[min(i) for i in rectangles]\n maxlen=max(maxlenL)\n return(ma | nidasaqib05 | NORMAL | 2022-05-19T18:51:53.797033+00:00 | 2022-05-19T18:51:53.797063+00:00 | 152 | false | def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n maxlenL=[min(i) for i in rectangles]\n maxlen=max(maxlenL)\n return(maxlenL.count(maxlen)) | 1 | 0 | ['Python', 'Python3'] | 0 |
number-of-rectangles-that-can-form-the-largest-square | Python3 | python3-by-excellentprogrammer-sua4 | \nclass Solution:\n def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n s=[]\n for i in range(len(rectangles)):\n s | ExcellentProgrammer | NORMAL | 2022-05-13T12:52:44.773832+00:00 | 2022-05-13T12:52:44.773862+00:00 | 36 | false | ```\nclass Solution:\n def countGoodRectangles(self, rectangles: List[List[int]]) -> int:\n s=[]\n for i in range(len(rectangles)):\n s.append(min(rectangles[i]))\n return(s.count(max(s)))\n``` | 1 | 0 | [] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Sort and skip | sort-and-skip-by-votrubac-7tmd | C++\ncpp\nint minimumDifference(vector<int>& nums, int k) {\n int res = INT_MAX;\n sort(begin(nums), end(nums));\n for (int i = k - 1; i < nums.size(); | votrubac | NORMAL | 2021-08-29T04:46:54.185968+00:00 | 2021-08-29T04:46:54.186001+00:00 | 9,084 | false | **C++**\n```cpp\nint minimumDifference(vector<int>& nums, int k) {\n int res = INT_MAX;\n sort(begin(nums), end(nums));\n for (int i = k - 1; i < nums.size(); ++i)\n res = min(res, nums[i] - nums[i - k + 1]);\n return res;\n}\n``` | 67 | 4 | [] | 13 |
minimum-difference-between-highest-and-lowest-of-k-scores | Python simple solution | python-simple-solution-by-tovam-c2pm | Python :\n\n\ndef minimumDifference(self, nums: List[int], k: int) -> int:\n\tif len(nums) <= 1:\n\t\treturn 0\n\n\tnums = sorted(nums)\n\tres = nums[k-1] - num | TovAm | NORMAL | 2021-10-30T19:40:22.100198+00:00 | 2021-10-30T20:43:26.092467+00:00 | 6,557 | false | **Python :**\n\n```\ndef minimumDifference(self, nums: List[int], k: int) -> int:\n\tif len(nums) <= 1:\n\t\treturn 0\n\n\tnums = sorted(nums)\n\tres = nums[k-1] - nums[0]\n\n\tfor i in range(k, len(nums)):\n\t\tres = min(res, nums[i] - nums[i - k + 1])\n\n\treturn res\n```\n\n**Like it ? please upvote !** | 35 | 0 | ['Python', 'Python3'] | 2 |
minimum-difference-between-highest-and-lowest-of-k-scores | C++ Simple and Clean 4-Line Explained Solution | c-simple-and-clean-4-line-explained-solu-khnl | Idea:\nSort the array.\nThen, we use a window of size k and calculate the difference between the first and last element in the window.\nres will be the minimum | yehudisk | NORMAL | 2021-08-29T12:25:06.753221+00:00 | 2021-08-29T12:26:33.288616+00:00 | 4,030 | false | **Idea:**\nSort the array.\nThen, we use a window of size k and calculate the difference between the first and last element in the window.\n`res` will be the minimum of these values.\n**Time Complexity:** O(nlogn)\n**Space Complexity:** O(1)\n```\nclass Solution {\npublic:\n int minimumDifference(vector<int>& nums, ... | 24 | 2 | ['C'] | 2 |
minimum-difference-between-highest-and-lowest-of-k-scores | JAVA | Sorting | Sliding Window | java-sorting-sliding-window-by-sourin_br-7d9b | Please Upvote :D\n\nclass Solution {\n public int minimumDifference(int[] nums, int k) {\n if (k == 1) return 0;\n\n Arrays.sort(nums);\n\t\t\n | sourin_bruh | NORMAL | 2022-11-17T18:28:38.000979+00:00 | 2022-11-17T18:28:46.976937+00:00 | 3,440 | false | ### **Please Upvote** :D\n```\nclass Solution {\n public int minimumDifference(int[] nums, int k) {\n if (k == 1) return 0;\n\n Arrays.sort(nums);\n\t\t\n int i = 0, j = k - 1, \n min = Integer.MAX_VALUE;\n\n while (j < nums.length) {\n min = Math.min(min, nums[j++] - nu... | 19 | 0 | ['Sliding Window', 'Sorting', 'Java'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Very Fast || Explained line by line || Easy to understand | very-fast-explained-line-by-line-easy-to-otgs | Intuition\n Describe your first thoughts on how to solve this problem. \nOur intution is to calculate minimum possible differance between maxmimum and minimum o | anand_shukla1312 | NORMAL | 2024-08-26T14:08:34.798363+00:00 | 2024-08-26T14:17:40.785787+00:00 | 1,816 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nOur intution is to calculate minimum possible differance between maxmimum and minimum of any K integer from given arry `nums`.\n\n---\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- **Sorting:** If we sort the li... | 14 | 0 | ['Sliding Window', 'Sorting', 'Iterator', 'Python3'] | 2 |
minimum-difference-between-highest-and-lowest-of-k-scores | [Java] Sorting, O(NlogN) | java-sorting-onlogn-by-blackpinklisa-nm3i | We can sort the array and then compare every element at index i with the element at index i+k-1. Take the minimum difference of all such pairs.\n\nTime Complexi | blackpinklisa | NORMAL | 2021-08-29T04:44:53.331639+00:00 | 2021-08-29T04:44:53.331670+00:00 | 2,359 | false | We can sort the array and then compare every element at index `i` with the element at index `i+k-1`. Take the minimum difference of all such pairs.\n\nTime Complexity - O(NlogN)\nSpace Complexity - O(1)\n```\nclass Solution {\n public int minimumDifference(int[] nums, int k) {\n Arrays.sort(nums);\n in... | 14 | 1 | [] | 4 |
minimum-difference-between-highest-and-lowest-of-k-scores | O(nlogn) || Sliding Window || 4 Line Solution || Explanation | onlogn-sliding-window-4-line-solution-ex-1yoj | The logic is that after sorting the array in ascending order it will be divided into n windows of k sizes\n\nEg :- [9,4,1,7]\nSort :- [1,4,7,9]\n\nNow the quest | aayushme | NORMAL | 2021-08-29T04:02:08.032198+00:00 | 2021-09-28T02:00:31.668084+00:00 | 3,036 | false | **The logic is that after sorting the array in ascending order it will be divided into n windows of k sizes**\n\nEg :- `[9,4,1,7]`\nSort :- `[1,4,7,9]`\n\nNow the question simply becomes find the minimum difference between lowest and highest element of window of size k **Windows :- `[1,4] [4,7] [7,9]`**\nAnswer = `m... | 14 | 1 | [] | 5 |
minimum-difference-between-highest-and-lowest-of-k-scores | Java solution using sliding window. | java-solution-using-sliding-window-by-sa-0s5q | Intuition\n Describe your first thoughts on how to solve this problem. \nIf we sort the array then the the min difference occurs at the neighbours\n\n# Approach | saivinaybathula22 | NORMAL | 2023-06-27T10:42:31.870740+00:00 | 2023-06-27T10:42:31.870764+00:00 | 2,403 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf we sort the array then the the min difference occurs at the neighbours\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe sork the array and create a sliding window of size k.\n\n# Complexity\n- Time complexity:... | 11 | 0 | ['Java'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Python-3- sliding window | python-3-sliding-window-by-abuomar2-2fu8 | Slide the window and update the min. each time we increase the window, if needed!\n\n\ndef minimumDifference(self, nums: List[int], k: int) -> int:\n num | abuomar2 | NORMAL | 2021-08-31T05:04:40.336263+00:00 | 2021-08-31T05:05:51.684343+00:00 | 2,371 | false | Slide the window and update the min. each time we increase the window, if needed!\n\n```\ndef minimumDifference(self, nums: List[int], k: int) -> int:\n nums.sort()\n l, r = 0, k-1\n \n minDiff = float(\'inf\')\n \n while r < len(nums):\n minDiff = min(minDiff, nums[... | 11 | 0 | ['Sliding Window', 'Sorting', 'Python', 'Python3'] | 3 |
minimum-difference-between-highest-and-lowest-of-k-scores | simple solution | simple-solution-by-aneesh-aj-bzap | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Aneesh-aj | NORMAL | 2023-11-14T05:29:25.017420+00:00 | 2023-11-14T05:29:25.017444+00:00 | 857 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 10 | 0 | ['JavaScript'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Easiest Solution | [C++] | Basic Approach | easiest-solution-c-basic-approach-by-ksh-3khd | Approach\n Describe your approach to solving the problem. \nIf we have to take difference of MAX and MIN Element in a pack of K elements, then why not sort it a | kshzz24 | NORMAL | 2023-02-25T14:36:11.725864+00:00 | 2023-02-25T14:36:11.725910+00:00 | 2,046 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nIf we have to take difference of MAX and MIN Element in a pack of K elements, then why not sort it and take 2 Pointers placed at 0th Position and (0+k-1)th Position respectively and take the difference of both and continue the same process until array... | 9 | 0 | ['C++'] | 1 |
minimum-difference-between-highest-and-lowest-of-k-scores | Python || 99.43% Faster || Sliding Window + Sorting | python-9943-faster-sliding-window-sortin-nsgf | \nclass Solution:\n def minimumDifference(self, nums: List[int], k: int) -> int:\n nums.sort()\n m,n=100001,len(nums)\n i,j=0,k-1\n | pulkit_uppal | NORMAL | 2022-11-30T21:57:25.014149+00:00 | 2022-11-30T22:08:08.653387+00:00 | 1,928 | false | ```\nclass Solution:\n def minimumDifference(self, nums: List[int], k: int) -> int:\n nums.sort()\n m,n=100001,len(nums)\n i,j=0,k-1\n while j<n:\n m=min(m,nums[j]-nums[i])\n i+=1\n j+=1\n return m\n```\n\n**An upvote will be encouraging** | 9 | 0 | ['Sliding Window', 'Sorting', 'Python', 'Python3'] | 1 |
minimum-difference-between-highest-and-lowest-of-k-scores | Python || C++ || Just sort | python-c-just-sort-by-_helios-v14t | Python\n\nclass Solution:\n def minimumDifference(self, nums: List[int], k: int) -> int:\n nums.sort()\n answer=9999999999\n for i in ra | _helios | NORMAL | 2021-08-29T04:35:18.223376+00:00 | 2021-08-29T04:35:18.223423+00:00 | 774 | false | Python\n```\nclass Solution:\n def minimumDifference(self, nums: List[int], k: int) -> int:\n nums.sort()\n answer=9999999999\n for i in range(0,len(nums)-k+1):\n val=nums[i+k-1]-nums[i]\n answer=min(answer,val)\n return answer\n \n```\n\n\nC++\n```\nclass Sol... | 7 | 1 | [] | 2 |
minimum-difference-between-highest-and-lowest-of-k-scores | [Python3] 1-Liner | python3-1-liner-by-blackspinner-2nqw | \nclass Solution:\n def minimumDifference(self, nums: List[int], k: int) -> int:\n return min(y - x for x, y in zip(sorted(nums)[:-k + 1], sorted(nums | blackspinner | NORMAL | 2021-08-30T06:19:18.394568+00:00 | 2021-08-30T06:19:18.394615+00:00 | 880 | false | ```\nclass Solution:\n def minimumDifference(self, nums: List[int], k: int) -> int:\n return min(y - x for x, y in zip(sorted(nums)[:-k + 1], sorted(nums)[k - 1:])) if k > 1 else 0\n``` | 6 | 0 | [] | 3 |
minimum-difference-between-highest-and-lowest-of-k-scores | ✔️ Easy C++ || 97% Faster || 70% Space || Sliding Window | easy-c-97-faster-70-space-sliding-window-zy3q | \nint minimumDifference(vector<int>& nums, int k) {\n sort(nums.begin(),nums.end());\n int ans = 100000;\n for(int i=k-1;i<nums.size();++i)\n an | soorajks2002 | NORMAL | 2022-04-09T09:48:46.174415+00:00 | 2022-04-09T09:48:46.174444+00:00 | 1,477 | false | ```\nint minimumDifference(vector<int>& nums, int k) {\n sort(nums.begin(),nums.end());\n int ans = 100000;\n for(int i=k-1;i<nums.size();++i)\n ans = min(ans, nums[i]-nums[i-k+1]);\n return ans;\n}\n``` | 5 | 1 | ['C', 'Sliding Window', 'Sorting', 'C++'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Java easy solution (sorting and sliding) | java-easy-solution-sorting-and-sliding-b-76bv | ```\n public int minimumDifference(int[] nums, int k) {\n Arrays.sort(nums);\n int minDiff = Integer.MAX_VALUE;\n for(int i=0;i=k-1) minDif | tusharkandwal99 | NORMAL | 2022-02-15T06:28:34.729699+00:00 | 2022-02-15T06:28:34.729726+00:00 | 2,012 | false | ```\n public int minimumDifference(int[] nums, int k) {\n Arrays.sort(nums);\n int minDiff = Integer.MAX_VALUE;\n for(int i=0;i<nums.length;i++){\n if(i>=k-1) minDiff = Math.min(minDiff,nums[i]-nums[i-(k-1)]);\n }\n return minDiff;\n } | 5 | 0 | ['Sliding Window', 'Java'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | [Python3] greedy 2-line | python3-greedy-2-line-by-ye15-nezu | Please see this commit for solutions of weekly 256.\n\n\nclass Solution:\n def minimumDifference(self, nums: List[int], k: int) -> int:\n nums.sort()\ | ye15 | NORMAL | 2021-08-29T17:01:22.871761+00:00 | 2021-08-30T04:23:22.724912+00:00 | 371 | false | Please see this [commit](https://github.com/gaosanyong/leetcode/commit/7abfd85d1a68e375fcc0be60558909fd98b270f3) for solutions of weekly 256.\n\n```\nclass Solution:\n def minimumDifference(self, nums: List[int], k: int) -> int:\n nums.sort()\n return min(nums[i+k-1]-nums[i] for i in range(len(nums)-k+... | 5 | 0 | ['Python3'] | 1 |
minimum-difference-between-highest-and-lowest-of-k-scores | C++ | EASY TO UNDERSTAND WITH EXPLAINATION | c-easy-to-understand-with-explaination-b-3mhr | Intuition\n Describe your first thoughts on how to solve this problem. \nSorting the array seems like a sensible approach to finding the minimum difference betw | nikhil_mane | NORMAL | 2024-03-06T23:26:56.232378+00:00 | 2024-03-06T23:26:56.232398+00:00 | 668 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSorting the array seems like a sensible approach to finding the minimum difference between elements in the array. With the sorted array, we can then iterate through sliding windows of size k and find the minimum difference within these wi... | 4 | 0 | ['Python', 'C++', 'Java'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Simple Soltuion || Sliding Window || Sort || Javascript | simple-soltuion-sliding-window-sort-java-yekb | \n\n/*\n * @param {number[]} nums\n * @param {number} k\n * @return {number}\n /\nvar minimumDifference = function(nums, k) {\n nums.sort((a,b)=>a-b)\n le | cursedcoder7 | NORMAL | 2022-02-18T04:11:48.854602+00:00 | 2022-02-18T04:11:56.929464+00:00 | 1,014 | false | ```\n\n```/**\n * @param {number[]} nums\n * @param {number} k\n * @return {number}\n */\nvar minimumDifference = function(nums, k) {\n nums.sort((a,b)=>a-b)\n let min=nums[0],max=nums[k-1],diff=max-min\n for(let i=k;i<nums.length;i++){\n diff=Math.min(diff,nums[i]-nums[i-k+1])\n }\n return diff\n... | 4 | 0 | ['Sliding Window', 'Sorting', 'JavaScript'] | 2 |
minimum-difference-between-highest-and-lowest-of-k-scores | JavaScript - brute force with sliding window | javascript-brute-force-with-sliding-wind-e2rt | \nvar minimumDifference = function(nums, k) {\n nums.sort((a,b)=>a-b);\n if(k===1)\n {\n return 0;\n }\n var n = nums.length;\n var res | jialihan | NORMAL | 2021-08-29T04:55:02.461789+00:00 | 2021-08-29T04:55:02.461829+00:00 | 894 | false | ```\nvar minimumDifference = function(nums, k) {\n nums.sort((a,b)=>a-b);\n if(k===1)\n {\n return 0;\n }\n var n = nums.length;\n var res = Infinity;\n for(var i = 0; i<= n-k; i++)\n {\n res = Math.min(res, nums[i+k-1]-nums[i]);\n }\n return res;\n};\n``` | 4 | 0 | ['JavaScript'] | 1 |
minimum-difference-between-highest-and-lowest-of-k-scores | a few solutions | a-few-solutions-by-claytonjwong-1zfk | Sort the input array A, then perform a linear scan to find and return the minimal difference of each "k away" values i..i + k - 1 as the best answer.\n\n---\n\n | claytonjwong | NORMAL | 2021-08-29T04:00:47.666749+00:00 | 2021-08-29T04:22:58.647567+00:00 | 712 | false | Sort the input array `A`, then perform a linear scan to find and return the minimal difference of each "`k` away" values `i..i + k - 1` as the `best` answer.\n\n---\n\n*Kotlin*\n```\nclass Solution {\n fun minimumDifference(A: IntArray, k: Int): Int {\n var best = (1e9 + 7).toInt()\n A.sort()\n ... | 4 | 0 | [] | 2 |
minimum-difference-between-highest-and-lowest-of-k-scores | Minimum difference || easy Sliding window approach || 100% beat | minimum-difference-easy-sliding-window-a-22st | Intuition
Sorting the array helps because once the array is sorted, the subarray with the smallest difference between its maximum and minimum values will be a c | rajpal1905 | NORMAL | 2025-01-20T13:18:21.488703+00:00 | 2025-01-20T13:18:21.488703+00:00 | 634 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
- Sorting the array helps because once the array is sorted, the subarray with the smallest difference between its maximum and minimum values will be a contiguous block of k elements.
- By simply comparing the first and last elements of thes... | 3 | 0 | ['C++'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | ✅✔️Short and Easy || C++ || Sorting || Sliding Window ✈️✈️✈️✈️✈️ | short-and-easy-c-sorting-sliding-window-nshgb | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | ajay_1134 | NORMAL | 2023-06-15T04:54:05.966644+00:00 | 2023-06-15T04:54:05.966669+00:00 | 641 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 3 | 0 | ['Array', 'Sliding Window', 'Sorting', 'C++'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Java Easy 4 lines solution | java-easy-4-lines-solution-by-avadarshve-1hc4 | \n Add your space complexity here, e.g. O(n) \n\n# Code\n\nclass Solution {\n public int minimumDifference(int[] nums, int k) {\n \n Arrays.sor | avadarshverma737 | NORMAL | 2023-01-31T08:20:56.369336+00:00 | 2023-01-31T08:20:56.369365+00:00 | 1,008 | false | \n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int minimumDifference(int[] nums, int k) {\n \n Arrays.sort(nums);\n int diff = nums[k-1]-nums[0];\n for(int i=k;i<nums.length;i++){\n diff = Math.min(nums[i]-nums[i-k+1],diff);\n... | 3 | 0 | ['Sorting', 'Java'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | C++ Solution | c-solution-by-nagaraj08-lfka | \n# Code\n\nclass Solution {\npublic:\n int minimumDifference(vector<int>& nums, int k) {\n \n sort(nums.begin(),nums.end());\n\n int left | NAGARAJ08 | NORMAL | 2023-01-14T12:09:30.474101+00:00 | 2023-01-17T07:35:04.470618+00:00 | 1,069 | false | \n# Code\n```\nclass Solution {\npublic:\n int minimumDifference(vector<int>& nums, int k) {\n \n sort(nums.begin(),nums.end());\n\n int left=0,right=k-1;\n\n int result =100000;\n\n while(right<nums.size())\n {\n result=min(result,nums[right]-nums[left]);\n ... | 3 | 0 | ['Sorting', 'C++'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Min Diff || Sliding Window || Two Pointer || Sorting | min-diff-sliding-window-two-pointer-sort-o3mz | Intuition\nSort it and then run a sliding window of size K.\n\n# Approach\n Describe your approach to solving the problem. \nSort the Array.\n\nSo now for every | 0sachin00 | NORMAL | 2022-10-22T07:08:12.864147+00:00 | 2022-10-22T07:08:12.864185+00:00 | 489 | false | # Intuition\nSort it and then run a sliding window of size K.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSort the Array.\n\nSo now for every K number of elements(i.e. One window) the *max = last element* of that window and the *min = first element* of that window. Determine the difference.\... | 3 | 0 | ['Two Pointers', 'Sliding Window', 'Sorting', 'Java'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | C++ EASY SOLUTION :) | c-easy-solution-by-amitzzz-ikpz | \nclass Solution {\npublic:\n int minimumDifference(vector<int>& nums, int k) \n {\n int diff=INT_MAX;\n sort(nums.begin(),nums.end());\n | AMITZZZ | NORMAL | 2022-09-26T18:18:42.681353+00:00 | 2022-09-26T18:18:42.681395+00:00 | 807 | false | ```\nclass Solution {\npublic:\n int minimumDifference(vector<int>& nums, int k) \n {\n int diff=INT_MAX;\n sort(nums.begin(),nums.end());\n \n int i=0,j=0;\n \n while(j<nums.size())\n {\n if(j-i+1<k)\n {\n j++;\n }\n... | 3 | 0 | ['C', 'Sliding Window', 'Sorting'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Java solution | nLogn & O(1) | 5ms & Faster than 81% | java-solution-nlogn-o1-5ms-faster-than-8-vohp | \nclass Solution {\n public int minimumDifference(int[] nums, int k) {\n if(nums.length==1) return 0;\n Arrays.sort(nums);\n int n= k-1; | razoan | NORMAL | 2022-03-07T19:10:25.315189+00:00 | 2022-03-07T19:10:25.315236+00:00 | 295 | false | ```\nclass Solution {\n public int minimumDifference(int[] nums, int k) {\n if(nums.length==1) return 0;\n Arrays.sort(nums);\n int n= k-1;\n int minDiff = Math.abs(nums[0]-nums[n]);\n for(int i=1; i<nums.length-n; i++) {\n int min = Math.abs(nums[i]-nums[i+n]);\n ... | 3 | 0 | [] | 1 |
minimum-difference-between-highest-and-lowest-of-k-scores | Java Sorting and Sliding Window | java-sorting-and-sliding-window-by-joyes-dlq9 | \nclass Solution {\n public int minimumDifference(int[] A, int k) {\n \n Arrays.sort(A);\n \n int start=0;\n int end=k-1;\n | joyesh | NORMAL | 2022-03-03T09:25:07.832634+00:00 | 2022-03-03T09:25:07.832674+00:00 | 537 | false | ```\nclass Solution {\n public int minimumDifference(int[] A, int k) {\n \n Arrays.sort(A);\n \n int start=0;\n int end=k-1;\n int OvrMin=Integer.MAX_VALUE;\n \n int N=A.length;\n //after sorting in a window of size k the smallest no is at start and highe... | 3 | 0 | ['Sliding Window', 'Sorting', 'Java'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Rust solution | rust-solution-by-bigmih-yidq | \nimpl Solution {\n pub fn minimum_difference(mut nums: Vec<i32>, k: i32) -> i32 {\n nums.sort_unstable();\n nums.windows(k as usize)\n | BigMih | NORMAL | 2021-08-29T10:43:26.420961+00:00 | 2021-08-29T10:43:51.045346+00:00 | 143 | false | ```\nimpl Solution {\n pub fn minimum_difference(mut nums: Vec<i32>, k: i32) -> i32 {\n nums.sort_unstable();\n nums.windows(k as usize)\n .map(|pair| pair[(k - 1) as usize] - pair[0])\n .min()\n .unwrap()\n }\n}\n``` | 3 | 0 | ['Sliding Window', 'Rust'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Easy and Short 5 line of code With Explanation | easy-and-short-5-line-of-code-with-expla-n5c5 | Steps``\n1. First we sort the array in increasing order.\n2. Now we consider every window of size k .\n3. in each window we find difference between Max and Min | JNVJS11 | NORMAL | 2021-08-29T07:39:31.790349+00:00 | 2021-08-29T07:52:24.611373+00:00 | 205 | false | * **Steps**``\n1. First we sort the array in increasing order.\n2. Now we consider every window of size k .\n3. in each window we find difference between Max and Min element,\n4. we return our Minimum difference of all the vlaues in step 3.\n**Code**\n\'\'\'\n int minimumDifference(vector<int>& nums, int k) {\n ... | 3 | 2 | ['C', 'Sliding Window', 'Sorting', 'C++'] | 1 |
minimum-difference-between-highest-and-lowest-of-k-scores | 1984. Minimum Difference Between Highest and Lowest of K Scores | 1984-minimum-difference-between-highest-ttg04 | ---\n\nThis looks a bit difficult for an Easy problem\n\n---\n\nHope it is simple to understand.\n\n---\n\n\nvar minimumDifference = function (nums, k) {\n r | pgmreddy | NORMAL | 2021-08-29T04:30:51.924817+00:00 | 2021-08-29T04:30:51.924845+00:00 | 1,667 | false | ---\n\nThis looks a bit difficult for an Easy problem\n\n---\n\nHope it is simple to understand.\n\n---\n\n```\nvar minimumDifference = function (nums, k) {\n return nums.length === 1\n ? 0\n : nums\n .sort((a, b) => a - b)\n .reduce(\n (minDiff, _, i) =>\n ... | 3 | 0 | ['JavaScript'] | 2 |
minimum-difference-between-highest-and-lowest-of-k-scores | C++ || sorting || easy solution | c-sorting-easy-solution-by-vineet_raosah-5fdq | \nclass Solution {\npublic:\n int minimumDifference(vector<int>& nums, int k) {\n int diff=INT_MAX;\n sort(nums.begin(),nums.end());\n f | VineetKumar2023 | NORMAL | 2021-08-29T04:02:24.278507+00:00 | 2021-08-29T04:02:24.278544+00:00 | 175 | false | ```\nclass Solution {\npublic:\n int minimumDifference(vector<int>& nums, int k) {\n int diff=INT_MAX;\n sort(nums.begin(),nums.end());\n for(int i=0;i<=nums.size()-k;i++)\n {\n diff=min(diff,nums[i+k-1]-nums[i]);\n }\n return diff;\n }\n};\n``` | 3 | 0 | [] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Easiest Solution || C++ || Beginner Approach | easiest-solution-c-beginner-approach-by-q8ndd | Beats 75% in Time Complexity\n\n\n\n# Code\n\nclass Solution {\npublic:\n int minimumDifference(vector<int>& nums, int k) {\n int n=nums.size();\n | sanon2025 | NORMAL | 2024-03-23T11:51:45.585298+00:00 | 2024-03-23T11:51:45.585323+00:00 | 677 | false | # Beats 75% in Time Complexity\n\n\n\n# Code\n```\nclass Solution {\npublic:\n int minimumDifference(vector<int>& nums, int k) {\n int n=nums.size();\n if(n==1... | 2 | 0 | ['C++'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Simple Solution | simple-solution-by-adwxith-w3a8 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | adwxith | NORMAL | 2023-11-14T04:42:07.222983+00:00 | 2023-11-14T04:42:07.223016+00:00 | 210 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 2 | 0 | ['JavaScript'] | 0 |
minimum-difference-between-highest-and-lowest-of-k-scores | Python3 Beats 99% sliding window of length K | python3-beats-99-sliding-window-of-lengt-ilty | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | gagemac | NORMAL | 2023-07-30T21:42:07.984374+00:00 | 2023-07-30T21:42:07.984392+00:00 | 781 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 2 | 0 | ['Python3'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.