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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
maximum-rows-covered-by-columns | C++ || solution | c-solution-by-soujash_mandal-cw2u | \nclass Solution {\npublic:\n int bits(int n)\n {\n int count = 0;\n while (n) {\n n =n& (n - 1);\n count++;\n | soujash_mandal | NORMAL | 2022-09-03T16:02:57.817593+00:00 | 2022-09-03T16:09:27.019948+00:00 | 62 | false | ```\nclass Solution {\npublic:\n int bits(int n)\n {\n int count = 0;\n while (n) {\n n =n& (n - 1);\n count++;\n }\n return count;\n }\n int binexp(int x,int n){\n int a=x;\n int prod=1;\n while(n)\n {\n if(n%2==1)prod... | 1 | 0 | [] | 1 |
maximum-rows-covered-by-columns | [JAVA] Bit-mask backtracking | java-bit-mask-backtracking-by-pr0d1g4ls0-2ja6 | \nclass Solution {\n int max = 0;\n int mask = 1073741823;\n int n;\n public int maximumRows(int[][] mat, int cols) {\n int[] state = new int | pr0d1g4ls0n | NORMAL | 2022-09-03T16:01:45.156593+00:00 | 2022-09-03T16:01:45.156639+00:00 | 65 | false | ```\nclass Solution {\n int max = 0;\n int mask = 1073741823;\n int n;\n public int maximumRows(int[][] mat, int cols) {\n int[] state = new int[mat.length];\n n = mat[0].length;\n for (int i = 0; i < mat.length; i++) {\n for (int j = 0; j < mat[0].length; j++) {\n ... | 1 | 0 | ['Backtracking', 'Bitmask'] | 0 |
maximum-rows-covered-by-columns | Gnerate all permutation || Easy to understand || C++ | gnerate-all-permutation-easy-to-understa-zj2x | \nclass Solution {\npublic:\n int ans;\n int covered(vector<vector<int>>& mat,vector<int>&nums){\n int count=0;\n for(int i=0;i<mat.size();i | Ankitkr437 | NORMAL | 2022-09-03T16:01:44.851654+00:00 | 2022-09-03T16:02:39.548253+00:00 | 75 | false | ```\nclass Solution {\npublic:\n int ans;\n int covered(vector<vector<int>>& mat,vector<int>&nums){\n int count=0;\n for(int i=0;i<mat.size();i++){\n int f=1;\n for(int j=0;j<mat[0].size();j++){\n if(mat[i][j]==1 && nums[j]==0) f=0;\n }\n if... | 1 | 0 | ['C', 'Probability and Statistics'] | 0 |
maximum-rows-covered-by-columns | C++ Solution Beats 100% | c-solution-beats-100-by-dakshg-nyzn | Code | dakshg | NORMAL | 2025-04-12T06:54:11.341495+00:00 | 2025-04-12T06:54:11.341495+00:00 | 1 | false | # Code
```cpp []
class Solution {
public:
int maximumRows(vector<vector<int>> &matrix, int numSelect) {
int n = matrix.size(),
m = matrix[0].size();
vector<int> comp(n);
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j)
comp[i] |= (matrix[... | 0 | 0 | ['C++'] | 0 |
maximum-rows-covered-by-columns | Recursive | Python 3 | Beats 70% | recursive-python-3-beats-60-by-zhan1803-qhtx | IntuitionCollect rows whose col_idx = 1 into a dictionary, and enumerate columns picked, to see which has the max coverageApproachrow dictionary:
dic[row] = [i, | zhan1803 | NORMAL | 2025-04-04T02:38:10.320616+00:00 | 2025-04-04T03:13:55.500690+00:00 | 2 | false | # Intuition
Collect rows whose col_idx = 1 into a dictionary, and enumerate columns picked, to see which has the max coverage
# Approach
row dictionary:
dic[row] = [i, j, k] # column index with the cell [row, i] = 1
Enumerate all possible selection of columns with amount = numSelect
During enumeration, we have two c... | 0 | 0 | ['Backtracking', 'Matrix', 'Enumeration', 'Python3'] | 0 |
maximum-rows-covered-by-columns | 【Java】2 Solutions Using Backtracking (+Pruning) | java-2-solutions-using-backtracking-prun-p3q7 | Solution 1: Choose or Not ChooseCodeSolution 2: Pickup One Col from Remaining ColsCode | AlanChao8669 | NORMAL | 2025-02-21T16:56:25.715638+00:00 | 2025-02-21T16:56:25.715638+00:00 | 5 | false | # Solution 1: Choose or Not Choose

# Code
```java []
class Solution {
int max;
boolean[] selected; // record selected cols
int selectedNum;
int m,n;
public int maximumRows(int[][] ma... | 0 | 0 | ['Java'] | 0 |
maximum-rows-covered-by-columns | 2397. Maximum Rows Covered by Columns | 2397-maximum-rows-covered-by-columns-by-ezuxf | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | G8xd0QPqTy | NORMAL | 2025-01-18T13:58:20.405472+00:00 | 2025-01-18T13:58:20.405472+00:00 | 10 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Python3'] | 0 |
maximum-rows-covered-by-columns | [Java] ✅ 1MS ✅ DFS ✅ PICK OR SKIP | java-1ms-dfs-pick-or-skip-by-stefanelsta-c9qs | Approach
Get the count of 1s for each row. Use an int[matrix.length] onesCount.
For each index, decide to select that column or to pick that column
Picking a co | StefanelStan | NORMAL | 2025-01-07T09:39:57.741845+00:00 | 2025-01-07T09:39:57.741845+00:00 | 9 | false | # Approach
1. Get the count of 1s for each row. Use an int[matrix.length] onesCount.
2. For each index, decide to select that column or to pick that column
3. Picking a column will mean the onesCount[] will decrease for each row where that column has 1. Decrease the count for each row, but also restore it when before r... | 0 | 0 | ['Java'] | 0 |
maximum-rows-covered-by-columns | NO BITMASK | Full Intuition✅Backtracking | C++ | no-bitmask-full-intuitionbacktracking-c-l60h9 | IntuitionStraight forward backtracking, only covered rows calculation is bit tricky and difficult to understandApproach
Generate all possible cols subset of siz | Heatw4ve | NORMAL | 2025-01-02T16:41:00.070629+00:00 | 2025-01-02T16:41:00.070629+00:00 | 3 | false | # Intuition
Straight forward backtracking, only covered rows calculation is bit tricky and difficult to understand
# Approach
1. Generate all possible cols subset of size exactly numSelect
2. A row is only considered valid, if all of the 1's that are present in that row, is in our current subset of cols
# Complexity
... | 0 | 0 | ['Backtracking', 'Matrix', 'C++'] | 0 |
maximum-rows-covered-by-columns | BackTracking | backtracking-by-linda2024-7r0y | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | linda2024 | NORMAL | 2024-12-24T00:08:37.523786+00:00 | 2024-12-24T00:08:37.523786+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['C#'] | 0 |
maximum-rows-covered-by-columns | very simple solution 🥷beats 💯🤟 | very-simple-solution-beats-by-sudharsan3-3ecx | \n\n# Code\njava []\nclass Solution {\n public int maximumRows(int[][] matrix, int numSelect) {\n int n = matrix.length;\n int m = matrix[0].le | sudharsan3112 | NORMAL | 2024-11-30T18:44:59.901688+00:00 | 2024-11-30T18:44:59.901717+00:00 | 6 | false | \n\n# Code\n```java []\nclass Solution {\n public int maximumRows(int[][] matrix, int numSelect) {\n int n = matrix.length;\n int m = matrix[0].length;\n if (numSelect > m) return 0;\n\n boolean[] taken = new boolean[m];\n return find(0, 0, n, m, matrix, numSelect, taken);\n }\n... | 0 | 0 | ['Java'] | 0 |
maximum-rows-covered-by-columns | C# Brute Force with combinatorics | c-brute-force-with-combinatorics-by-getr-a804 | Intuition\n- Describe your first thoughts on how to solve this problem. When approaching this problem, the first intuition involves systematically identifying | GetRid | NORMAL | 2024-11-25T18:47:09.461588+00:00 | 2024-11-25T18:47:09.461623+00:00 | 0 | false | # Intuition\n- <!-- Describe your first thoughts on how to solve this problem. -->When approaching this problem, the first intuition involves systematically identifying the columns that contribute most to row coverage. A brute-force solution immediately comes to mind due to the following factors: The Problem\'s Small S... | 0 | 0 | ['Array', 'Backtracking', 'Bit Manipulation', 'Matrix', 'Enumeration', 'C#'] | 0 |
maximum-rows-covered-by-columns | [C++] Backtracking | c-backtracking-by-wcf29-qolp | Intuition\n Describe your first thoughts on how to solve this problem. \n\nUsing backtracking.\n\nfor a col with index i, there are two decisions: choose it and | wcf29 | NORMAL | 2024-11-08T21:37:26.377223+00:00 | 2024-11-08T21:37:26.377249+00:00 | 5 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nUsing backtracking.\n\nfor a col with index i, there are two decisions: choose it and not choose it.\n\nSo the decision tree is like: \n\n " "\n / \\\n " " "0" \n / \\ / \\\n ... | 0 | 0 | ['C++'] | 0 |
maximum-rows-covered-by-columns | Backtrack solution beats 70% | backtrack-solution-beats-70-by-gopigaura-ngtn | 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 | gopigaurav | NORMAL | 2024-11-02T08:16:37.221031+00:00 | 2024-11-02T08:16:37.221054+00:00 | 10 | 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)$$ --... | 0 | 0 | ['Python3'] | 0 |
maximum-rows-covered-by-columns | Fast Solution | fast-solution-by-dshrey27-f9hq | 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 | dshrey279 | NORMAL | 2024-10-20T11:56:45.716265+00:00 | 2024-10-20T11:56:45.716304+00:00 | 1 | 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)$$ --... | 0 | 0 | ['C++'] | 0 |
maximum-rows-covered-by-columns | Java backtrack | java-backtrack-by-noturproblem-efbq | 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 | noturproblem | NORMAL | 2024-10-16T18:15:25.398960+00:00 | 2024-10-16T18:15:25.398992+00:00 | 1 | 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)$$ --... | 0 | 0 | ['Java'] | 0 |
maximum-rows-covered-by-columns | Easy to follow c++ code | easy-to-follow-c-code-by-ashkanxy-k1an | Intuition\n\nFinding all combination of the columns (question 77) and check the maximum covered rows by each of them and return the maximum.\n\n\n# Approach\n\n | ashkanxy | NORMAL | 2024-10-11T01:23:00.623765+00:00 | 2024-10-11T01:24:07.020230+00:00 | 5 | false | # Intuition\n\nFinding all combination of the columns (question 77) and check the maximum covered rows by each of them and return the maximum.\n\n\n# Approach\n\n1, Generate all combinations of columns with a size of numSelect. For instance, for a matrix with 4 columns and k=2, the combinations are {{0,1}, {0,2}, {0,3}... | 0 | 0 | ['Backtracking', 'Combinatorics', 'C++'] | 0 |
maximum-rows-covered-by-columns | Simple and Intuitive Java Solution | Beats 100%! | simple-and-intuitive-java-solution-beats-hcxk | Approach\nBacktrack through all possible solutions with length equal to numSelect.\n\nMark visited elements in a boolean array selected and check if the selecte | hmanolov | NORMAL | 2024-10-08T06:26:08.356529+00:00 | 2024-10-08T06:26:08.356560+00:00 | 1 | false | # Approach\nBacktrack through all possible solutions with length equal to `numSelect`.\n\nMark visited elements in a boolean array `selected` and check if the selected row count exceeds the maximum, when enough elements are selected.\n\n# Code\n```java []\nclass Solution {\n int maxCount = 0;\n public int maximum... | 0 | 0 | ['Backtracking', 'Java'] | 0 |
maximum-containers-on-a-ship | ⌚ONE-LINER⌚| O(1)🚀 || [C++/Java/Py3/JS]⚡EASY SOLUTION w EXPLANATION🍨 | one-liner-o1-cjavapy3jseasy-solution-w-e-e8st | IntuitionThe problem requires us to determine the maximum number of containers that can be placed on an n x n cargo deck while ensuring the total weight does no | Fawz-Haaroon | NORMAL | 2025-03-23T05:10:31.791258+00:00 | 2025-03-23T17:04:58.792534+00:00 | 1,288 | false | ## Intuition
The problem requires us to determine the maximum number of containers that can be placed on an `n x n` cargo deck while ensuring the total weight does not exceed `maxWeight`.
- The deck can hold at most `n * n` containers.
- Each container has a weight of `w`, so the total weight of all `k` container... | 17 | 0 | ['Math', 'Python', 'C++', 'Java', 'Python3', 'JavaScript'] | 1 |
maximum-containers-on-a-ship | Simple check | simple-check-by-kreakemp-4lqe | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code
Here is an article of my last interview experience - A Journey to FAANG Company, I recomand | kreakEmp | NORMAL | 2025-03-23T04:02:47.814455+00:00 | 2025-03-23T04:43:23.111829+00:00 | 697 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 9 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Easy & Detailed Solution✅ |TC: O(1) 🔥 | Step - By - Step Explain 🚀 | C++ | Java | Py | Js | easy-detailed-solution-step-by-step-expl-7we4 | 🧠 IntuitionThe problem requires us to determine the maximum number of containers that can be placed on an n x n desk while ensuring that their total weight does | himanshu_dhage | NORMAL | 2025-03-23T04:03:18.513466+00:00 | 2025-03-23T04:09:40.072774+00:00 | 549 | false | # 🧠 Intuition
The problem requires us to determine the maximum number of containers that can be placed on an `n x n` desk while ensuring that their total weight does not exceed `maxWeight`.
- The **total number of containers** that can fit on the desk is `n * n`.
- Each container has a weight of `w`.
- The go... | 5 | 1 | ['C++', 'Java', 'Python3', 'JavaScript'] | 1 |
maximum-containers-on-a-ship | JS | Two approach | Math (or) Binary search | O(1) | Beats 100% 🚀 | js-binary-search-beats-100-by-akashcse20-vl1z | ApproachJust maths.Complexity
Time complexity: O(1)
Space complexity: O(1)
CodeApproachWe can use Binary Search algorithm which efficiently searches for the max | akashcse2000 | NORMAL | 2025-03-23T04:03:42.832528+00:00 | 2025-03-23T04:20:17.128140+00:00 | 256 | false | # Approach
Just maths.
# Complexity
- Time complexity: O(1)
- Space complexity: O(1)
# Code
```javascript []
var maxContainers = function(n, w, m) {
if((n * n * w) <= m) return n * n;
return Math.floor(m / w);
};
```
# Approach
We can use Binary Search algorithm which efficiently searches for the maximum nu... | 4 | 0 | ['JavaScript'] | 3 |
maximum-containers-on-a-ship | 100% Beats || One Line Of Code | 100-beats-one-line-of-code-by-kdhakal-lsnx | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | kdhakal | NORMAL | 2025-04-09T13:41:17.139927+00:00 | 2025-04-09T13:41:17.139927+00:00 | 14 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 3 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | One Linear | one-linear-by-charnavoki-leld | null | charnavoki | NORMAL | 2025-03-24T09:24:43.722659+00:00 | 2025-03-24T09:24:43.722659+00:00 | 51 | false |
```javascript []
const maxContainers = (n, w, max) => Math.min(n * n, max / w) | 0;
``` | 3 | 0 | ['JavaScript'] | 0 |
maximum-containers-on-a-ship | beats 100% using binary search | beats-100-using-binary-search-by-s_malay-gz5s | Complexity
Time complexity:O(logn)
Space complexity:O(1)
Code | s_malay | NORMAL | 2025-03-23T05:08:41.518003+00:00 | 2025-03-23T05:08:41.518003+00:00 | 103 | false |
# Complexity
- Time complexity:O(logn)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```cpp []
class Solution {
public:
int possible(int mid,int &w,int &maxWeight)
{
if(mid*w <=maxWeight)return true;
return false;... | 3 | 0 | ['Binary Search', 'C++'] | 1 |
maximum-containers-on-a-ship | 🌟 Beats 100.00% || Python3 One Line 💯🔥🗿 | beats-10000-python3-one-line-by-emmanuel-uuga | ApproachJust check that hint and convert to integer.Code | emmanuel011 | NORMAL | 2025-03-23T04:17:33.648774+00:00 | 2025-03-23T04:17:33.648774+00:00 | 115 | false | # Approach
Just check that hint and convert to integer.
# Code
```python3 []
class Solution:
def maxContainers(self, n: int, w: int, maxWeight: int) -> int:
return int(min(n * n, maxWeight / w))
``` | 3 | 0 | ['Python3'] | 3 |
maximum-containers-on-a-ship | [Python, Java, C++] Elegant & Short | Math | python-elegant-short-math-by-kyrylo-ktl-ccq1 | Complexity
Time complexity: O(1)
Space complexity: O(1)
Code | Kyrylo-Ktl | NORMAL | 2025-03-24T08:04:57.666004+00:00 | 2025-03-24T08:17:27.159070+00:00 | 53 | false | # Complexity
- Time complexity: $$O(1)$$
- Space complexity: $$O(1)$$
# Code
```python3 []
class Solution:
def maxContainers(self, n: int, w: int, max_weight: int) -> int:
return min(n * n, max_weight // w)
```
```Java []
class Solution {
public int maxContainers(int n, int w, int maxWeight) {
... | 2 | 0 | ['Math', 'Python', 'C++', 'Java', 'Python3'] | 0 |
maximum-containers-on-a-ship | Binary search | Beats 100% | binary-search-beats-100-by-alishershaest-4zts | Code | alishershaesta | NORMAL | 2025-03-23T09:18:41.449672+00:00 | 2025-03-23T09:18:41.449672+00:00 | 16 | false | # Code
```python3 []
class Solution:
def maxContainers(self, n: int, w: int, maxWeight: int) -> int:
l, r = 1, n*n
result = 0
while l <= r:
mid = l + ((r-l)//2)
if (mid * w) > maxWeight:
r = mid - 1
else:
l = mid + 1
... | 2 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | Easiest C++ | O(1) | Just 2 Lines | Explained | easiest-c-o1-just-2-lines-explained-by-a-1i2j | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | AK200199 | NORMAL | 2025-03-23T06:46:34.162160+00:00 | 2025-03-23T06:46:34.162160+00:00 | 81 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 2 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | ✅ ⟣ Java Solution ⟢ | java-solution-by-harsh__005-u8is | Code | Harsh__005 | NORMAL | 2025-03-23T04:03:55.283128+00:00 | 2025-03-23T04:03:55.283128+00:00 | 129 | false | # Code
```java []
class Solution {
public int maxContainers(int n, int w, int maxWeight) {
return Math.min(n*n, maxWeight/w);
}
}
``` | 2 | 0 | ['Java'] | 1 |
maximum-containers-on-a-ship | Straight forward beginner friendly solution😊✅✅ | straight-forward-beginner-friendly-solut-au2v | Intuition:We need to load as many containers as possible without exceeding the maxWeight. Each container weighs w, and there are n containers available.Approach | nilestiwari_7 | NORMAL | 2025-03-23T04:02:18.202347+00:00 | 2025-03-23T04:02:18.202347+00:00 | 32 | false | ### Intuition:
We need to load as many containers as possible without exceeding the `maxWeight`. Each container weighs `w`, and there are `n` containers available.
### Approach:
1. Start with `count = 0` and `wt = 0`.
2. While there are containers left and we can add one more without exceeding `maxWeight`, load the co... | 2 | 0 | ['Greedy', 'C++', 'Python3', 'JavaScript'] | 0 |
maximum-containers-on-a-ship | Beats 100.00% | beats-10000-by-darwadenidhi174-h6tc | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | darwadenidhi174 | NORMAL | 2025-04-11T15:41:50.274103+00:00 | 2025-04-11T15:41:50.274103+00:00 | 7 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | Easy One Liner | 0ms Runtime | Beats 100%🥷🏻✨ | easy-one-liner-0ms-runtime-beats-100-by-2wplq | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | tyagideepti9 | NORMAL | 2025-03-31T17:28:39.168879+00:00 | 2025-03-31T17:28:39.168879+00:00 | 18 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 1 | 0 | ['Math', 'C#'] | 0 |
maximum-containers-on-a-ship | ☑️ Finding Maximum Containers on a Ship. ☑️ | finding-maximum-containers-on-a-ship-by-8to85 | Code | Abdusalom_16 | NORMAL | 2025-03-31T16:04:20.718377+00:00 | 2025-03-31T16:04:20.718377+00:00 | 9 | false | # Code
```dart []
class Solution {
int maxContainers(int n, int w, int maxWeight) {
int sum = 0;
for(int i = 1; i <= n*n; i++){
sum += w;
if(maxWeight < sum){
return i-1;
}
}
return n*n;
}
}
``` | 1 | 0 | ['Math', 'Dart'] | 0 |
maximum-containers-on-a-ship | 📦 Easy & Shorter Solution: Maximum Containers in an n × n Grid Under Weight Constraint ⚖️ | easy-shorter-solution-maximum-containers-a246 | IntuitionThe problem requires determining the maximum number of containers that can be placed in an ( n * n ) grid while ensuring that the total weight does not | Jils_Patel | NORMAL | 2025-03-29T12:22:30.886353+00:00 | 2025-03-29T12:22:30.886353+00:00 | 10 | false | # Intuition
The problem requires determining the maximum number of containers that can be placed in an \( n * n \) grid while ensuring that the total weight does not exceed `maxWeight`.
- First, we calculate the total number of containers that can fit in the grid, which is \( n^2 \).
- Then, we determine how many c... | 1 | 0 | ['Python'] | 0 |
maximum-containers-on-a-ship | Just one line solution😂😂😂😂😂, beats 100% of the solutions. | just-one-line-solution-beats-100-of-the-urutx | Code | adityamah2002 | NORMAL | 2025-03-27T13:31:38.079271+00:00 | 2025-03-27T13:31:38.079271+00:00 | 14 | false | # Code
```java []
class Solution {
public int maxContainers(int n, int w, int maxWeight) {
return Math.min(maxWeight/w, n*n);
}
}
``` | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | One-liner | Beats 100% | Python3 | one-liner-beats-100-python3-by-alpha2404-o09b | Please UpvoteCode | Alpha2404 | NORMAL | 2025-03-25T16:35:09.956558+00:00 | 2025-03-25T16:35:09.956558+00:00 | 18 | false | # Please Upvote
# Code
```python3 []
class Solution:
def maxContainers(self, n: int, w: int, maxWeight: int) -> int:
return min(maxWeight//w,n*n)
``` | 1 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | 📦 Maximum Containers Calculation | maximum-containers-calculation-by-akhild-3og8 | Intuition🚀 IntuitionThe problem requires us to calculate the maximum number of containers that can be used while considering two constraints:Since we need the m | akhildas675 | NORMAL | 2025-03-25T04:01:33.308708+00:00 | 2025-03-25T04:01:33.308708+00:00 | 6 | false | # Intuition
🚀 Intuition
The problem requires us to calculate the maximum number of containers that can be used while considering two constraints:
1. The total number of available containers, which is n * n (assuming a square arrangement).
2. The weight constraint, which limits the number of containers based... | 1 | 0 | ['JavaScript'] | 0 |
maximum-containers-on-a-ship | EASY C++ 100% O(1) | easy-c-100-o1-by-hnmali-un6t | Code | hnmali | NORMAL | 2025-03-24T17:34:44.727115+00:00 | 2025-03-24T17:34:44.727115+00:00 | 9 | false |
# Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight) {
return min(n * n, maxWeight / w);
}
};
``` | 1 | 0 | ['Math', 'C++'] | 0 |
maximum-containers-on-a-ship | Linear time Solution | linear-time-solution-by-sumitksr-fdca | Code | sumitksr | NORMAL | 2025-03-24T14:16:03.235603+00:00 | 2025-03-24T14:16:03.235603+00:00 | 7 | false | # Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight) {
return min(n * n, maxWeight / w);
}
};
``` | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Easy C++ solution | Beats 100 % | easy-c-solution-beats-100-by-anuragpal01-k8r1 | IntuitionThe problem requires us to determine the maximum number of containers that can be loaded onto an n x n cargo deck without exceeding a given weight limi | Anuragpal010104 | NORMAL | 2025-03-24T08:48:00.593767+00:00 | 2025-03-24T08:48:00.593767+00:00 | 6 | false | # Intuition
The problem requires us to determine the maximum number of containers that can be loaded onto an n x n cargo deck without exceeding a given weight limit. Since each cell can hold exactly one container of weight w, we must balance the number of containers with the ship’s maximum weight capacity
<!-- Describe... | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Hmm..One Line | hmmone-line-by-runningfalcon-ft5d | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | runningfalcon | NORMAL | 2025-03-23T23:04:04.384956+00:00 | 2025-03-23T23:04:04.384956+00:00 | 11 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 1 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | O(1) Solution one linear Basic class 7th Maths | o1-solution-one-linear-basic-class-7th-m-zd5f | IntuitionApproachComplexity
Time complexity:
O(1)
Space complexity:
O(1)
Code | utk50090 | NORMAL | 2025-03-23T18:17:47.444883+00:00 | 2025-03-23T18:17:47.444883+00:00 | 11 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
- O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
- O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$... | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Calculating Maximum Containers on a Ship Deck Using Weight and Capacity Constraints | calculating-maximum-containers-on-a-ship-wi4a | IntuitionThe problem requires determining the maximum number of containers that can be loaded onto an n×n cargo deck without exceeding the ship's maximum weight | x7Fg9_K2pLm4nQwR8sT3vYz5bDcE6h | NORMAL | 2025-03-23T17:14:14.855132+00:00 | 2025-03-23T17:14:14.855132+00:00 | 67 | false | # Intuition
The problem requires determining the maximum number of containers that can be loaded onto an n×n cargo deck without exceeding the ship's maximum weight capacity. My first thought was to calculate the total number of cells on the deck and compare it with the maximum number of containers allowed by the weight... | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Easy Solution | easy-solution-by-jordon-x-matter-0h2a | IntuitionApproachComplexity
Time complexity: O(1)
Space complexity: O(1)
Code | Jordon-x-Matter | NORMAL | 2025-03-23T15:52:59.711868+00:00 | 2025-03-23T15:52:59.711868+00:00 | 7 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity: O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->... | 1 | 0 | ['Math', 'C++'] | 0 |
maximum-containers-on-a-ship | O(1) time complexity || One liner || Java || Easiest Approach💯 | o1-time-complexity-one-liner-java-easies-m3i1 | IntuitionApproachComplexity
Time complexity:O(1)
Space complexity:O(1)
Code | aryaman123 | NORMAL | 2025-03-23T11:20:36.992989+00:00 | 2025-03-23T11:21:04.440807+00:00 | 22 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
... | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | 0ms 100% O(1) fmin | stdmin-by-michelusa-27ze | O(1)Cfmin() from the math libraryC++ | michelusa | NORMAL | 2025-03-23T11:07:06.005998+00:00 | 2025-03-23T11:22:11.429560+00:00 | 20 | false | O(1)
# C
fmin() from the math library
```c []
int maxContainers(int n, int w, int maxWeight) {
return w ? fmin(n * n, maxWeight / w) : 0;
}
```
# C++
```cpp []
class Solution {
public:
int maxContainers(const int n, const int w, const int maxWeight) {
return w ? std::min(n * n, maxWeight / w) : 0;
... | 1 | 0 | ['C', 'C++'] | 0 |
maximum-containers-on-a-ship | Beats 100%,Easisest Solution, One-Liner | beats-100easisest-solution-by-harshbhush-8r0z | IntuitionApproachComplexity
Time complexity:O(1)
Space complexity:0(1)
Code | Harshbhushandixit | NORMAL | 2025-03-23T11:01:06.289738+00:00 | 2025-03-23T11:01:38.983015+00:00 | 19 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:0(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
... | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-by-danisd-dagh | Code | DanisDeveloper | NORMAL | 2025-03-23T10:48:38.267847+00:00 | 2025-03-23T10:48:38.267847+00:00 | 14 | false |
# Code
```python3 []
class Solution:
def maxContainers(self, n: int, w: int, maxWeight: int) -> int:
return min(n * n, maxWeight // w)
``` | 1 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | My Solution O(1) time complexity|| easy solution | my-solution-o1-time-complexity-easy-solu-34hi | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Preetam_123Pandey | NORMAL | 2025-03-23T08:56:42.138280+00:00 | 2025-03-23T08:56:42.138280+00:00 | 11 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | C++ GRANDMASTER LEGENDARY SOLUTION ;) | c-grandmaster-legendary-solution-by-half-x0jq | Code | Half-Dimension | NORMAL | 2025-03-23T08:52:53.807651+00:00 | 2025-03-23T08:52:53.807651+00:00 | 13 | false | # Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight) {
int cells=n*n;
if(cells*w<=maxWeight){
return cells;
}
return maxWeight/w;
}
};
``` | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Linear | O(1) 👽| cpp 🤩 | linear-o1-cpp-by-varuntyagig-vcla | Code | varuntyagig | NORMAL | 2025-03-23T08:51:02.318621+00:00 | 2025-03-23T08:51:02.318621+00:00 | 8 | false | # Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight) {
int total_Containers = n * n;
int max_Container_loads = maxWeight / w;
if (total_Containers <= max_Container_loads) {
return total_Containers;
}
return max_Container_load... | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | 100percent Affective code in JAVA | 100percent-affective-code-in-java-by-anu-obya | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | anuragk2 | NORMAL | 2025-03-23T08:28:53.675665+00:00 | 2025-03-23T08:28:53.675665+00:00 | 5 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | Simple 2 line code | Easily Understandable | O(1) time complexity | Java | Beats 100% | simple-2-line-code-easily-understandable-vl3p | Complexity
Time complexity:O(1)
Space complexity:O(1)
Code | Aditya_Yadav_ | NORMAL | 2025-03-23T08:25:28.718478+00:00 | 2025-03-23T08:25:28.718478+00:00 | 3 | false |
# Complexity
- Time complexity:$$O(1)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:$$O(1)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```java []
class Solution {
public int maxContainers(int n, int w, int maxWeight) {
if(n*n*w < maxWeight) return (n*n);
... | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | <<0 LINER CODE || BEAT 100% SOLUTIONS>> | 0-liner-code-beat-100-solutions-by-daksh-gzwd | PLEASE UPVOTE MECode | Dakshesh_vyas123 | NORMAL | 2025-03-23T08:21:00.232799+00:00 | 2025-03-23T08:21:00.232799+00:00 | 5 | false | # PLEASE UPVOTE ME
# Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight) {
return min((maxWeight/w),(n*n));
}
};
``` | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Maximum Containers That Can Be Filled | maximum-containers-that-can-be-filled-by-5iqc | IntuitionThe problem requires determining the maximum number of containers that can be filled given:Total available space: The number of containers that can fit | Sarthak_Kharwade | NORMAL | 2025-03-23T07:08:22.957149+00:00 | 2025-03-23T07:08:22.957149+00:00 | 14 | false | # Intuition
The problem requires determining the maximum number of containers that can be filled given:
Total available space: The number of containers that can fit in a given area, which is n * n.
Weight constraint: Each container has a fixed weight w, and the total weight cannot exceed maxWeight.
### **Your Approac... | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | simple solutions with 100% beat | simple-solutions-with-100-beat-by-vinay_-r3vr | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | vinay_kumar_swami | NORMAL | 2025-03-23T06:59:17.161146+00:00 | 2025-03-23T06:59:17.161146+00:00 | 7 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | cpp | cpp-by-ajay__j-7ejk | Code | Ajay__J | NORMAL | 2025-03-23T06:36:11.990578+00:00 | 2025-03-23T06:36:11.990578+00:00 | 7 | false |
# Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight) {
int ans=0;
for (int i=0;i<(n*n);i++){
if ((ans+1)*w>maxWeight) return ans;
ans++;
}
return ans;
}
};
``` | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Simple without loops O(1) TC&SC solution||EASY SOLUTION✅ | simple-without-loops-o1-tcsc-solutioneas-mfan | IntuitionSee they have asked the min num of decks that can be stored, so what you can do is without running a loop find n*n and maxWeigbt/w (to find the num of | Gaurav_SK | NORMAL | 2025-03-23T05:24:49.913903+00:00 | 2025-03-23T05:24:49.913903+00:00 | 6 | false | # Intuition
See they have asked the min num of decks that can be stored, so what you can do is without running a loop find n*n and maxWeigbt/w (to find the num of decks which can be stored in the deck)
# Approach
<!-- Describe your approach to solving the problem. -->
declare the variables to calculate
# Complexity
-... | 1 | 0 | ['Math', 'C++'] | 0 |
maximum-containers-on-a-ship | C++ Easy Solution | c-easy-solution-by-namanverma01-azs5 | Code | namanverma01 | NORMAL | 2025-03-23T05:23:47.141366+00:00 | 2025-03-23T05:23:47.141366+00:00 | 28 | false |
# Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight) {
int desk=n*n;
int ans=0;
for(int i=desk;i>=0;i--)
{
if(desk*w<=maxWeight)
{
ans=desk;
break;
}
else{
desk--;
}
}... | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Half Line | O(1) | Rust | half-line-o1-rust-by-prog_jacob-ypjx | Complexity
Time complexity: O(1)
Space complexity: O(1)
Code | Prog_Jacob | NORMAL | 2025-03-23T04:55:32.694982+00:00 | 2025-03-23T04:55:32.694982+00:00 | 8 | false | # Complexity
- Time complexity: $$O(1)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: $$O(1)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```rust []
impl Solution {
pub fn max_containers(n: i32, w: i32, max_weight: i32) -> i32 {
(n * n * w).min(max_weight) /... | 1 | 0 | ['Rust'] | 0 |
maximum-containers-on-a-ship | Beats 100% || Math 🚀🚀🚀🚀 | beats-100-math-by-dheeraj_2602-pk0i | IntuitionThe problem involves maximizing the number of containers we can fill, given a constraint on individual container weight and the total allowable weight. | Dheeraj_2602 | NORMAL | 2025-03-23T04:43:38.100134+00:00 | 2025-03-23T04:43:38.100134+00:00 | 11 | false | # Intuition
The problem involves maximizing the number of containers we can fill, given a constraint on individual container weight and the total allowable weight. The two limiting factors are:
Total number of containers available: 𝑛^2 (since it’s an 𝑛×𝑛 grid of containers).
Maximum number of containers we can fil... | 1 | 0 | ['Math', 'Python', 'C++', 'Java'] | 0 |
maximum-containers-on-a-ship | 🚢 Max Containers on a Cargo Deck 🚢 | max-containers-on-a-cargo-deck-by-opwzpx-mnzz | 💡 Intuition:The problem requires us to determine the maximum number of containers that can be loaded onto an n×n cargo deck without exceeding the ship's weight | opWzPXRgDd | NORMAL | 2025-03-23T04:15:43.712812+00:00 | 2025-03-23T04:15:43.712812+00:00 | 35 | false | # 💡 Intuition:
<!-- Describe your first thoughts on how to solve this problem. -->
The problem requires us to determine the maximum number of containers that can be loaded onto an n×n cargo deck without exceeding the ship's weight capacity.
Each cell on the deck can hold exactly one container, meaning the maximum pos... | 1 | 0 | ['Greedy', 'Graph', 'Python3'] | 0 |
maximum-containers-on-a-ship | Easy and beginner friendly || O(1) || beats 💯🔥🔥 | easy-and-beginner-friendly-o1-by-codewit-a2bx | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | CodeWithMithun | NORMAL | 2025-03-23T04:15:02.903392+00:00 | 2025-03-23T04:16:32.530084+00:00 | 20 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->O(1)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->O(1)
#... | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Math || Java | math-java-by-akshay_kadamm-5f75 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Akshay_Kadamm | NORMAL | 2025-03-23T04:09:48.689431+00:00 | 2025-03-23T04:09:48.689431+00:00 | 12 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | Java || Beats 100% || Time Complexity : O(1) | java-beats-100-time-complexity-o1-by-shi-nmgz | Complexity
Time complexity: O(1)
Space complexity: O(1)
Code | shikhargupta0645 | NORMAL | 2025-03-23T04:09:17.987463+00:00 | 2025-03-23T04:09:17.987463+00:00 | 12 | false |
# Complexity
- Time complexity: O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```java []
class Solution {
public int maxContainers(int n, int w, int maxWeight) {
int c = n*n;
int count = maxWeight... | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | Python Code: it's work | python-code-its-work-by-bhav5sh-y0vn | IntuitionApproachComplexity
Time complexity: O(1)
Space complexity: O(1)
Code | Bhav5sh | NORMAL | 2025-03-23T04:08:24.915897+00:00 | 2025-03-23T04:08:24.915897+00:00 | 21 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity: O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | Java solution || Time Complexity : O(n) | java-solution-time-complexity-on-by-shik-d4fr | Complexity
Time complexity: O(n)
Space complexity: O(1)
Code | shikhargupta0645 | NORMAL | 2025-03-23T04:07:34.025270+00:00 | 2025-03-23T04:07:34.025270+00:00 | 14 | false |
# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```java []
class Solution {
public int maxContainers(int n, int w, int maxWeight) {
int count = 0;
int wt = 0;
... | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | One Liner | one-liner-by-tylerdurdn-obni | IntuitionApproachComplexity
Time complexity:
O(1)
Space complexity:
O(1)Code | tylerdurdn | NORMAL | 2025-03-23T04:05:28.344437+00:00 | 2025-03-23T04:05:28.344437+00:00 | 12 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(1)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1)... | 1 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | Simple Solution - Using just one line - Python/Java/C++ | simple-solution-using-just-one-line-pyth-jjcn | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | cryandrich | NORMAL | 2025-03-23T04:04:45.633210+00:00 | 2025-03-23T04:04:45.633210+00:00 | 3 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Easy Solution || Java || Python || C++ || 🚀🚀 || 🔥🔥 | easy-solution-java-python-c-by-vermaansh-g5iq | IntuitionApproachComplexity
Time complexity: O(1)
Space complexity: O(1)
Code | vermaanshul975 | NORMAL | 2025-03-23T04:04:09.047661+00:00 | 2025-03-23T04:04:09.047661+00:00 | 15 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity: O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->... | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | || ✅#DAY_64th_Of_Daily_Coding✅ || | day_64th_of_daily_coding-by-coding_with_-lyt0 | JAI SHREE DATNA🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏Code | Coding_With_Star | NORMAL | 2025-03-23T04:03:58.940832+00:00 | 2025-03-23T04:04:47.614641+00:00 | 16 | false | # JAI SHREE DATNA🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
# Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight) {
int totalSlots = n * n;
int maxByWeight = maxWeight / w;
return min(totalSlots, maxByWeight);
}
};
``` | 1 | 0 | ['C++', 'Java', 'Python3'] | 0 |
maximum-containers-on-a-ship | Java | Easy | One Line Solution | Beats 100% | java-easy-one-line-solution-beats-100-by-d41f | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Pankajj_42 | NORMAL | 2025-03-23T04:03:22.393113+00:00 | 2025-03-23T04:03:22.393113+00:00 | 15 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 1 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | Math | C++ | Simple One liner | math-c-simple-one-liner-by-thangakumaran-cpr6 | Complexity
Time complexity:
O (1)
Space complexity:
Code | Thangakumaran | NORMAL | 2025-03-23T04:03:17.988716+00:00 | 2025-03-23T04:03:17.988716+00:00 | 15 | false |
# Complexity
- Time complexity:
O (1)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O (1)
# Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight)
{
return ((maxWeight / w) <= (n * n)) ? (maxWeight / w) : (n * n);
}
};
``` | 1 | 0 | ['Math', 'C++'] | 0 |
maximum-containers-on-a-ship | Easiest 👇👇O(1) 🔥 Maximum Containers on a Ship ⚡ | easiest-o1-maximum-containers-on-a-ship-tx15t | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Vanshnigam | NORMAL | 2025-03-23T04:02:51.946823+00:00 | 2025-03-23T04:02:51.946823+00:00 | 90 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 1 | 0 | ['Array', 'C++', 'Java', 'Python3'] | 1 |
maximum-containers-on-a-ship | C++ 1 liner straightforward solution | c-1-liner-straightforward-solution-by-em-7hnu | Code | eminem18753 | NORMAL | 2025-03-23T04:02:39.626702+00:00 | 2025-03-23T04:02:39.626702+00:00 | 9 | false | # Code
```cpp []
class Solution
{
public:
int maxContainers(int n, int w, int maxWeight)
{
return min(n*n,maxWeight/w);
}
};
``` | 1 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Beats 100% || Simple and Easy Code | beats-100-simple-and-easy-code-by-balara-7956 | IntuitionThe problem aims to find the maximum number of containers that can be filled, given a certain number of items, weight per item, and maximum total weigh | Balarakesh | NORMAL | 2025-04-11T17:58:50.898157+00:00 | 2025-04-11T17:58:50.898157+00:00 | 1 | false | # Intuition
The problem aims to find the maximum number of containers that can be filled, given a certain number of items, weight per item, and maximum total weight. It involves calculating the maximum number of containers based on the number of items and the maximum number of containers based on the total weight const... | 0 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | Basic Mathematical Logic - Beats 100% | basic-mathematical-logic-beats-100-by-dw-00hr | Intuition
Basic Mathematical Logic
Approach
Calculate the maximal grid spaces available (nxn)
Calculate the maximum number of crates for weight restriction.
Tak | dworoniuk1 | NORMAL | 2025-04-10T14:53:44.371262+00:00 | 2025-04-10T14:53:44.371262+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
- Basic Mathematical Logic
# Approach
<!-- Describe your approach to solving the problem. -->
- Calculate the maximal grid spaces available (nxn)
- Calculate the maximum number of crates for weight restriction.
- Take minimum of two outc... | 0 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | Maximum Containers on a Ship | maximum-containers-on-a-ship-by-manish12-5ryk | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | manish120903 | NORMAL | 2025-04-10T12:22:15.900334+00:00 | 2025-04-10T12:22:15.900334+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | C++ solution | c-solution-by-niteeshn158227-g5yn | Code | niteeshn158227 | NORMAL | 2025-04-09T07:34:02.522894+00:00 | 2025-04-09T07:34:02.522894+00:00 | 1 | false | # Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight) {
int totalCells = n*n;
int totalWeight = totalCells*w;
if(totalWeight <=maxWeight) {
return totalCells;
}
while(totalWeight > maxWeight) {
totalCells--;
... | 0 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | one LINER (beats 100% runtime, 100% memory) | one-liner-beats-100-runtime-100-memory-b-e68j | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | dpasala | NORMAL | 2025-04-09T04:00:35.136732+00:00 | 2025-04-09T04:00:35.136732+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | Swift💯 tiny 1liner | swift-tiny-1liner-by-upvotethispls-tb5v | One-Liner (accepted answer) | UpvoteThisPls | NORMAL | 2025-04-08T23:06:45.371520+00:00 | 2025-04-08T23:06:45.371520+00:00 | 1 | false | **One-Liner (accepted answer)**
```
class Solution {
func maxContainers(_ n: Int, _ w: Int, _ maxWeight: Int) -> Int {
min(n*n, maxWeight/w)
}
}
``` | 0 | 0 | ['Swift'] | 0 |
maximum-containers-on-a-ship | Easiest and simplest Solution | easiest-and-simplest-solution-by-sdkv-tvuz | Complexity
Time complexity:
O(1)
Space complexity:
O(1)
Code | sdkv | NORMAL | 2025-04-08T12:06:04.892206+00:00 | 2025-04-08T12:06:04.892206+00:00 | 1 | false |
# Complexity
- Time complexity:
O(1)
- Space complexity:
O(1)
# Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight) {
if(maxWeight-n*n*w >= 0){
return n*n;
}else{
return maxWeight/w;
}
}
};
``` | 0 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Runtime 0 ms Beats 100.00% | runtime-0-ms-beats-10000-by-iamsd-8q9k | Code | iamsd_ | NORMAL | 2025-04-08T05:05:31.444222+00:00 | 2025-04-08T05:05:31.444222+00:00 | 1 | false | # Code
```java []
class Solution {
public int maxContainers(int n, int w, int maxWeight) {
return Math.min(n * n, maxWeight / w);
}
}
``` | 0 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | Java Solution | java-solution-by-a_shekhar-mawb | IntuitionApproachComplexity
Time complexity:
O(n)
Space complexity:
O(1)Code | a_shekhar | NORMAL | 2025-04-07T16:50:58.237073+00:00 | 2025-04-07T16:50:58.237073+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(n)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1)... | 0 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | Pure Math approach - beats 100% | pure-math-approach-beats-100-by-jbehak-h53z | Code | JBehak | NORMAL | 2025-04-07T15:18:51.906823+00:00 | 2025-04-07T15:18:51.906823+00:00 | 3 | false | # Code
```csharp []
public class Solution
{
public int MaxContainers(int n, int w, int maxWeight)
{
if (n * n * w > maxWeight)
{
return maxWeight / w;
}
else
{
return n * n;
}
}
}
``` | 0 | 0 | ['Math', 'C#'] | 0 |
maximum-containers-on-a-ship | Javascript one line solution | javascript-one-line-solution-by-meloman3-d0gv | IntuitionJavascript one line solutionComplexity
Time complexity: O(1)
Space complexity: O(1)
Code | meloman370 | NORMAL | 2025-04-06T16:38:19.130101+00:00 | 2025-04-06T16:38:19.130101+00:00 | 2 | false | # Intuition
Javascript one line solution
<!-- Describe your first thoughts on how to solve this problem. -->
# Complexity
- Time complexity: O(1)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```typescript []
function maxC... | 0 | 0 | ['TypeScript'] | 0 |
maximum-containers-on-a-ship | JavaScript - JS | javascript-js-by-mlienhart-leao | null | mlienhart | NORMAL | 2025-04-06T16:20:22.105022+00:00 | 2025-04-06T16:20:22.105022+00:00 | 1 | false | ```javascript []
/**
* @param {number} n
* @param {number} w
* @param {number} maxWeight
* @return {number}
*/
var maxContainers = function (n, w, maxWeight) {
return Math.min(Math.floor(maxWeight / w), n * n);
};
``` | 0 | 0 | ['JavaScript'] | 0 |
maximum-containers-on-a-ship | Simple solution PYTHON beats 100% | simple-solution-python-beats-100-by-shah-2ba1 | IntuitionApproachComplexity
Time complexity:
O(1)
Space complexity:
O(1)Code | shaheershakir | NORMAL | 2025-04-03T19:36:15.973355+00:00 | 2025-04-03T19:36:15.973355+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(1)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1)... | 0 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | Java Easy solution | java-easy-solution-by-anujpachauri-jhn8 | Intuition"Calculate the number of decks, then determine how many containers are needed to hold all the weights."Approach"Calculate the number of decks, then det | anujpachauri | NORMAL | 2025-04-01T12:21:21.079090+00:00 | 2025-04-01T12:21:21.079090+00:00 | 1 | false | # Intuition
"Calculate the number of decks, then determine how many containers are needed to hold all the weights."
# Approach
"Calculate the number of decks, then determine how many containers are needed to hold all the weights."
# Complexity
- Time complexity:
O(n)
- Space complexity:
O(n)
# Code
```java []
class... | 0 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | C++ One linear | c-one-linear-by-the_ghuly-2evp | Code | the_ghuly | NORMAL | 2025-04-01T08:41:29.362352+00:00 | 2025-04-01T08:41:29.362352+00:00 | 2 | false | # Code
```cpp []
class Solution {
public:
int maxContainers(int n, int w, int maxWeight) {
return min(maxWeight/w, n*n);
}
};
``` | 0 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Solution | solution-by-frolovdata0238-jda0 | ApproachNo one line solution, easy to understand.Complexity
Time complexity: O(1)
Space complexity: O(1)
Code | frolovdata0238 | NORMAL | 2025-04-01T05:57:41.777028+00:00 | 2025-04-01T05:57:41.777028+00:00 | 1 | false | # Approach
No one line solution, easy to understand.
# Complexity
- Time complexity: $$O(1)$$
- Space complexity: $$O(1)$$
# Code
```python3 []
class Solution:
def maxContainers(self, n: int, w: int, maxWeight: int) -> int:
max_count_of_containers = maxWeight // w
count_of_cells = n * n
... | 0 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | my solution | my-solution-by-leman_cap13-7ca0 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | leman_cap13 | NORMAL | 2025-03-31T13:13:38.110684+00:00 | 2025-03-31T13:13:38.110684+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | Use min to find max. | use-min-to-find-max-by-shaikh_muhaiminul-kq5r | IntuitionWe have to determine the maximum number of boxes we can take.We can reach the constraints in two ways either space or weight. We can take the lesser of | Shaikh_Muhaiminul_Hasan | NORMAL | 2025-03-30T18:05:03.030430+00:00 | 2025-03-30T18:05:03.030430+00:00 | 1 | false | # Intuition
We have to determine the maximum number of boxes we can take.We can reach the constraints in two ways either space or weight. We can take the lesser of the two constraints because if we reach the maximum space before weight then we take the maximum space and vice versa.
# Approach
We return the minimum of ... | 0 | 0 | ['Python3'] | 0 |
maximum-containers-on-a-ship | Luke - max containers solution | luke-max-containers-solution-by-thunderl-bwdp | IntuitionI thought that I had to do extra coding.ApproachI only needed the hint to do this. No knowledge needed. Just return the minimum of n squared and the ma | thunderlukey | NORMAL | 2025-03-29T23:59:08.090486+00:00 | 2025-03-29T23:59:08.090486+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
I thought that I had to do extra coding.
# Approach
<!-- Describe your approach to solving the problem. -->
I only needed the hint to do this. No knowledge needed. Just return the minimum of n squared and the maxweight/w. Just read the hint... | 0 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | Scala solution | scala-solution-by-iyieo99amh-27x2 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | iyIeO99AmH | NORMAL | 2025-03-29T14:58:41.692435+00:00 | 2025-03-29T14:58:41.692435+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Scala'] | 0 |
maximum-containers-on-a-ship | easy approach | easy-approach-by-sidgogia20-yx3e | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | sidgogia20 | NORMAL | 2025-03-29T12:01:20.651705+00:00 | 2025-03-29T12:01:20.651705+00:00 | 0 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['C++'] | 0 |
maximum-containers-on-a-ship | Possible and but | possible-and-but-by-dinesh0212kumar-r65q | IntuitionApproachComplexity
Time complexity:
O(1)
Space complexity:
O(1)Code | Dinesh0212Kumar | NORMAL | 2025-03-29T07:23:05.953459+00:00 | 2025-03-29T07:23:05.953459+00:00 | 2 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(1)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1)... | 0 | 0 | ['Java'] | 0 |
maximum-containers-on-a-ship | Containers on a Ship - Math.floor ( ) | containers-on-a-ship-mathfloor-by-zemamb-7e26 | null | zemamba | NORMAL | 2025-03-28T22:03:09.623365+00:00 | 2025-03-28T22:04:19.112280+00:00 | 2 | false | ```javascript []
var maxContainers = function(n, w, maxWeight) {
return Math.min(n * n, Math.floor(maxWeight / w))
};
``` | 0 | 0 | ['JavaScript'] | 0 |
maximum-containers-on-a-ship | Python 1 liner | python-1-liner-by-plavak_d10-m319 | Code | plavak_d10 | NORMAL | 2025-03-28T21:37:33.325770+00:00 | 2025-03-28T21:37:33.325770+00:00 | 1 | false |
# Code
```python3 []
class Solution:
def maxContainers(self, n: int, w: int, maxWeight: int) -> int:
return min(n*n,maxWeight//w)
``` | 0 | 0 | ['Python3'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.