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-number-of-k-divisible-components | Easiest way of solving and Understanding | easiest-way-of-solving-and-understanding-387r | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | shaik_raj | NORMAL | 2024-12-21T13:39:24.002889+00:00 | 2024-12-21T13:39:24.002889+00:00 | 32 | 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 | ['Tree', 'Depth-First Search', 'Breadth-First Search', 'Topological Sort', 'Python3'] | 0 |
maximum-number-of-k-divisible-components | Runtime 59ms beats 100% Memory 161MB beats 97.47% | runtime-59ms-beats-100-memory-161mb-beat-g1r7 | Code | Gabrielkq | NORMAL | 2024-12-21T12:39:30.697315+00:00 | 2024-12-21T12:39:30.697315+00:00 | 4 | false | # Code
```cpp []
class Solution {
public:
int maxKDivisibleComponents(int &n, vector<vector<int>>& _edges, vector<int>& values, int &k) {
vector<vector<int>> edges(n);
// optional
vector<int> degrees(n);
for(int i = 0; i < _edges.size(); i++)
{
++degrees... | 1 | 0 | ['C++'] | 0 |
maximum-number-of-k-divisible-components | Easy Solution. Easy TO UNderstand using dfs | easy-solution-easy-to-understand-using-d-3sug | IntuitionApproachComplexity
Time complexity:
O(n)
Space complexity:
O(n)
Code | HYDRO2070 | NORMAL | 2024-12-21T11:31:50.235839+00:00 | 2024-12-21T11:31:50.235839+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:
$$O(n)$$
- Space complexity:
$$O(n)$$
# Code
```cpp []
class Solution {
private:
vector<vector<int>> adj;
vector<bool> visit;... | 1 | 0 | ['C++'] | 0 |
maximum-number-of-k-divisible-components | DFS + Modulo Cleaner/Faster Than Ever | dfs-modulo-cleanerfaster-than-ever-by-lo-3xkc | IntuitionApproachComplexity
Time complexity:
The code exploits DFS for hierarchical traversal, leveraging modular arithmetic to efficiently determine valid c | loinguyen1905 | NORMAL | 2024-12-21T10:17:33.818193+00:00 | 2024-12-22T04:51:35.245933+00:00 | 35 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
 to visit each node and calculate the sum of values for all nodes in the same connected component.After visiting all nodes i | pranav743 | NORMAL | 2024-12-21T09:48:48.745256+00:00 | 2024-12-21T09:51:50.191250+00:00 | 48 | false | # Approach
Use Depth-First Search (DFS) to visit each node and calculate the sum of values for all nodes in the same connected component.
After visiting all nodes in a component, check if the sum of values is divisible by k. If yes, increment the count of such components.
# Complexity
- Time complexity: $$ O(N) $$
... | 1 | 0 | ['Depth-First Search', 'Graph', 'Python3'] | 0 |
maximum-number-of-k-divisible-components | Easy DFS❤️🔥DRY RUN❤️🔥MILDLY AROUSING🤤🤤 | easy-dfsdry-runmildly-arousing-by-intbli-lqtm | IntuitionThe problem asks us to find the maximum number of components in a tree such that the sum of values in each component is divisible by k. The key observa | intbliss | NORMAL | 2024-12-21T09:47:27.288798+00:00 | 2024-12-21T09:47:27.288798+00:00 | 41 | false | ### **Intuition**
The problem asks us to find the maximum number of components in a tree such that the sum of values in each component is divisible by `k`. The key observation is:
1. **Tree Properties**: A tree is a connected graph without cycles, so we can traverse the tree using Depth First Search (DFS).
2. **Divisib... | 1 | 0 | ['Java'] | 2 |
maximum-number-of-k-divisible-components | 100% faster🚀100% efficient ️🔥O(n) soln | 100-faster100-efficient-on-soln-by-harsh-jo3x | IntuitionReferenceComplexity
Time complexity:
O(n)
Space complexity:
O(1)
Code | harsh007kumar | NORMAL | 2024-12-21T09:39:01.560927+00:00 | 2024-12-21T09:41:28.885464+00:00 | 107 | false | # Intuition
DFS
# Reference
https://youtu.be/xlgOaIK-inc
# Complexity
- Time complexity:
O(n)
- Space complexity:
O(1)
# Code
```csharp []
public class Solution {
// Time O(n)| Space O(1)
public int MaxKDivisibleComponents(int n, int[][] edges, int[] values, int k) {
List<int>[] g = new List<int... | 1 | 0 | ['Tree', 'Depth-First Search', 'Graph', 'C++', 'Java', 'C#'] | 0 |
maximum-number-of-k-divisible-components | Just Plain Old DFS | just-plain-old-dfs-by-numan947-u6lv | IntuitionUsing DFS, we traverse the tree nodes while maintaining a running sum for each subtree rooted at a node. If the sum of a subtree is a multiple of ( k ) | numan947 | NORMAL | 2024-12-21T09:05:07.471919+00:00 | 2024-12-21T09:05:07.471919+00:00 | 20 | false | # Intuition
Using DFS, we traverse the tree nodes while maintaining a running sum for each subtree rooted at a node. If the sum of a subtree is a multiple of \( k \), it qualifies as a valid component. By counting these components and continuing the DFS, we can calculate the maximum number of valid components the tree ... | 1 | 0 | ['Python3'] | 0 |
maximum-number-of-k-divisible-components | Real Pure C Solution || Beats 100 % in time and memory | real-pure-c-solution-beats-100-in-time-a-qr7t | ApproachThe Approch of this problem is EasyWe use depth-first-search to compute the sum of each vertice if the sum % k == 0 then the tree for which the vertice | IsaacKingsleyD | NORMAL | 2024-12-21T08:56:35.386906+00:00 | 2024-12-21T08:56:35.386906+00:00 | 13 | false | # Approach
<!-- Describe your approach to solving the problem. -->
The Approch of this problem is Easy
We use depth-first-search to compute the sum of each vertice if the sum % k == 0 then the tree for which the vertice is the root can be valid split and increment the answer
After DFS we finally return the answer
# ... | 1 | 0 | ['Linked List', 'Tree', 'Depth-First Search', 'C'] | 0 |
maximum-number-of-k-divisible-components | 2872. Maximum Number of K-Divisible Components | 2872-maximum-number-of-k-divisible-compo-65k8 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | AdilShamim8 | NORMAL | 2024-12-21T08:34:50.229616+00:00 | 2024-12-21T08:34:50.229616+00:00 | 17 | 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-number-of-k-divisible-components | [C++] Easy DFS | c-easy-dfs-by-bora_marian-1mh5 | The key observation here is that: 'Sum of values is divisible by k'.The result of the problem is the number of nodes which the sum of the subtree values includi | bora_marian | NORMAL | 2024-12-21T08:22:17.620677+00:00 | 2024-12-21T08:25:04.130975+00:00 | 43 | false | The key observation here is that: 'Sum of values is divisible by k'.
The result of the problem is the number of nodes which the sum of the subtree values including the node is divisible by `k`.
I used DFS to calculate the sum of the subtree values for each node.
# Code
```cpp []
class Solution {
vector<int> sum;
... | 1 | 0 | ['C++'] | 0 |
maximum-number-of-k-divisible-components | Calculating subtree sums | calculating-subtree-sums-by-crankyinmv-s6ve | Stuff I did
The places to cut are unaffected by where the root of the tree is.
Calculate subtree sums starting from the leaves.
Any node whose subtree sum is a | crankyinmv | NORMAL | 2024-12-21T07:44:50.950053+00:00 | 2024-12-21T07:44:50.950053+00:00 | 22 | false | ### Stuff I did
- The places to cut are unaffected by where the root of the tree is.
- Calculate subtree sums starting from the leaves.
- Any node whose subtree sum is a multiple of k is a new component.
### Code
```javascript []
/**
* @param {number} n
* @param {number[][]} edges
* @param {number[]} values
* @pa... | 1 | 0 | ['JavaScript'] | 0 |
maximum-number-of-k-divisible-components | ✅C++✅Beats 100%🔥Python🔥|| 🚀🚀Super Simple and Efficient Solution🚀🚀||🔥Python🔥✅C++✅ | cbeats-100python-super-simple-and-effici-4ghs | Complexity
Time complexity: O(n)
Space complexity: O(n)
Code | shobhit_yadav | NORMAL | 2024-12-21T07:42:26.674800+00:00 | 2024-12-21T07:42:26.674800+00:00 | 41 | 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
```cpp []
class Solution {
public:
int maxKDivisibleComponents(int n, vector<vector<int>>& edges, vector<int>& values, int k) {
... | 1 | 0 | ['Depth-First Search', 'Graph', 'C++', 'Python3'] | 0 |
maximum-number-of-k-divisible-components | Postorder N-ary Tree | postorder-n-ary-tree-by-shourya_setu-be6s | IntuitionUsing postOrder TraversalApproachapplying the simple postorder traversal on n-ary treeComplexity
Time complexity: O(n)
Space complexity: O(n)
Code | Shourya_Setu | NORMAL | 2024-12-21T07:40:10.082817+00:00 | 2024-12-21T07:40:10.082817+00:00 | 25 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Using postOrder Traversal
# Approach
<!-- Describe your approach to solving the problem. -->
applying the simple postorder traversal on n-ary tree
# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->... | 1 | 0 | ['Tree', 'Java'] | 0 |
maximum-number-of-k-divisible-components | Java || Beats 93% || Easy to understand || Basic Approach | java-beats-93-easy-to-understand-basic-a-16qm | IntuitionApproachValues: [0,3,4,3,3,3,2,3]Original Tree:
Sum Tree: Represents the sum of values of all the child Nodes + value[i]
Here we have to count the node | IronEyrie | NORMAL | 2024-12-21T07:37:39.943915+00:00 | 2024-12-21T07:37:39.943915+00:00 | 57 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
`Values: [0,3,4,3,3,3,2,3]`
<!-- Describe your approach to solving the problem. -->
Original Tree:

Sum Tree: Rep... | 1 | 0 | ['Java'] | 0 |
maximum-number-of-k-divisible-components | Most Premium Question || Mind Testing || DFS || | most-premium-question-mind-testing-dfs-b-4gnw | Complexity
Time complexity : O(N)
Space complexity : O(N)
Code | Ashish_Ujjwal | NORMAL | 2024-12-21T07:35:58.945006+00:00 | 2024-12-21T07:35:58.945006+00:00 | 19 | 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
```cpp []
class Solution {
public:
int dfs(vector<vector<int>>&adj, vector<int>&values, int &k, int &count, int curr, int parent = -1... | 1 | 0 | ['Tree', 'Depth-First Search', 'C++'] | 0 |
maximum-number-of-k-divisible-components | Python Clean Code | Beat 96% | python-clean-code-beat-96-by-yt788-ydiz | Code | yt788 | NORMAL | 2024-12-21T07:22:38.524901+00:00 | 2024-12-21T07:22:38.524901+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... | 1 | 0 | ['Python3'] | 0 |
maximum-number-of-k-divisible-components | My solution : | my-solution-by-sayanyeager-qoyd | IntuitionA tree with n nodes labeled from 0 to n-1.
Edges given in pairs [a, b] that connect two nodes, forming the tree structure.
Values assigned to each node | sayanyeager | NORMAL | 2024-12-21T07:13:53.500197+00:00 | 2024-12-21T07:13:53.500197+00:00 | 28 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
A tree with n nodes labeled from 0 to n-1.
Edges given in pairs [a, b] that connect two nodes, forming the tree structure.
Values assigned to each node.
Divisor k — we need to divide the tree into groups such that the sum of values in each ... | 1 | 0 | ['Tree', 'Depth-First Search', 'C'] | 0 |
maximum-number-of-k-divisible-components | Maxximum Number of k- divisible components | maxximum-number-of-k-divisible-component-0fxn | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | asawari87 | NORMAL | 2024-12-21T06:54:21.926253+00:00 | 2024-12-21T06:54:21.926253+00:00 | 26 | 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 | ['JavaScript'] | 0 |
maximum-number-of-k-divisible-components | Maximum Number of k- divisible components | maximum-number-of-k-divisible-components-e0l0 | IntuitionThe problem involves finding the maximum number of connected components in a tree where the sum of node values in each component is divisible by
𝑘
k. T | asawari87 | NORMAL | 2024-12-21T06:51:25.311688+00:00 | 2024-12-21T06:51:25.311688+00:00 | 40 | false | # Intuition
The problem involves finding the maximum number of connected components in a tree where the sum of node values in each component is divisible by
𝑘
k. To achieve this:
Tree Structure: A tree is an acyclic connected graph, so removing edges can split it into multiple connected components.
Divisibility Con... | 1 | 0 | ['Java', 'JavaScript'] | 0 |
maximum-number-of-k-divisible-components | 📚 BUILD YOUR INTUITION! 📚 O(n log n) ==> O(n) - CREATIVE SOLUTION + CHALLENGE FOR YOU 🔥🔥🔥 | build-your-intuition-on-log-n-on-creativ-th9m | IntuitionFirstly, notice that whenever we remove an edge, we split the graph into two components.
After removing an edge, we will end up with a whole subtree (t | chinese_spy | NORMAL | 2024-12-21T06:48:20.282519+00:00 | 2024-12-21T06:57:54.677582+00:00 | 16 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Firstly, notice that whenever we remove an edge, we split the graph into two components.
After removing an edge, we will end up with a whole subtree (this can be a singular node), and a PARTIAL subtree.
Now, if the sum of all node values in... | 1 | 0 | ['Segment Tree', 'Prefix Sum', 'C++'] | 0 |
maximum-number-of-k-divisible-components | C++ DFS Solution | c-dfs-solution-by-vikas_verma-qf6m | IntuitionStarting from a node, reach the leafs of the tree, and start adding the values and return the sum value to parent node. If the value becomes divisible | vikas_verma | NORMAL | 2024-12-21T06:29:40.322507+00:00 | 2024-12-21T06:37:15.303114+00:00 | 34 | false | # Intuition
Starting from a node, reach the leafs of the tree, and start adding the values and return the sum value to parent node. If the value becomes divisible by `k` at a node (subtree sum is divisible by k) increament `count` (as we found a valid split) and return 0 sum value instead. The final `count` is the max ... | 1 | 0 | ['Tree', 'Depth-First Search', 'C++'] | 0 |
maximum-number-of-k-divisible-components | Easy Solution, DFS | easy-solution-dfs-by-dotuangv-vtbz | IntuitionApproachComplexity
Time complexity: O(n)
Space complexity: O(n)
Code | dotuangv | NORMAL | 2024-12-21T05:49:39.374072+00:00 | 2024-12-21T05:49:39.374072+00:00 | 8 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# 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)$$ -->... | 1 | 0 | ['Depth-First Search', 'C++'] | 0 |
maximum-number-of-k-divisible-components | Simple DFS solution works 😤 | simple-dfs-solution-works-by-deepsalunkh-yusv | Problem RestatementYou are given:
A tree with n nodes (an undirected connected graph with n-1 edges).
An array values of size n, where values[i] represents the | deepsalunkhee | NORMAL | 2024-12-21T05:42:32.581859+00:00 | 2024-12-21T05:42:32.581859+00:00 | 15 | false |
### Problem Restatement
You are given:
- A tree with `n` nodes (an undirected connected graph with `n-1` edges).
- An array `values` of size `n`, where `values[i]` represents the value of the `i-th` node.
- An integer `k`.
**Objective**: Determine the maximum number of components that can be created by removing some ... | 1 | 0 | ['C++', 'Java'] | 0 |
maximum-number-of-k-divisible-components | leetcodedaybyday - Beats 80,49% with Python3 and Beats 36,71% with C++ | leetcodedaybyday-beats-8049-with-python3-rir0 | IntuitionThe task requires finding the maximum number of components in a tree such that the sum of node values in each component is divisible by ( k ).
The key | tuanlong1106 | NORMAL | 2024-12-21T05:34:59.804232+00:00 | 2024-12-21T05:34:59.804232+00:00 | 15 | false | # **Intuition**
The task requires finding the maximum number of components in a tree such that the sum of node values in each component is divisible by \( k \).
The key observation is that whenever a subtree's total sum is divisible by \( k \), it can form a valid component. The problem can be efficiently solved usin... | 1 | 0 | ['C++', 'Python3'] | 0 |
maximum-number-of-k-divisible-components | TopoSort and BFS | toposort-and-bfs-by-dikshith12345ty-9act | IntuitionApproachCheck the degrees of node if its 1 it's leafnode check the condition if it satisfies cnt+1 or add the value to its neighbiur nodeComplexity
Tim | dikshith12345ty | NORMAL | 2024-12-21T03:59:44.732831+00:00 | 2024-12-21T03:59:44.732831+00:00 | 50 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
Check the degrees of node if its 1 it's leafnode check the condition if it satisfies cnt+1 or add the value to its neighbiur node
# Complexity
- Time complexity:O(n)
<!-- ... | 1 | 0 | ['C++'] | 0 |
maximum-number-of-k-divisible-components | easy DFS solution C | Runtime Beats 100.00% | Memory Beats 100.00% | easy-dfs-solution-c-runtime-beats-10000-qqgph | Intuition/ApproachAny node can be the parent node so we will choose zero to be the parent.
Keep track of all connections to each node and travel down them.
Once | JoshDave | NORMAL | 2024-12-21T03:57:50.873853+00:00 | 2024-12-21T04:00:24.819869+00:00 | 44 | false | # Intuition/Approach
Any node can be the parent node so we will choose zero to be the parent.
Keep track of all connections to each node and travel down them.
Once at a node with no more children, check to see if it could be cut (divisible by k).
If not then add it to its parent node and see if the parent node can be c... | 1 | 0 | ['Tree', 'Depth-First Search', 'C'] | 0 |
maximum-number-of-k-divisible-components | typescript solution | typescript-solution-by-lainhdev-z4x7 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | lainhdev | NORMAL | 2024-12-21T02:18:17.473078+00:00 | 2024-12-21T02:18:17.473078+00:00 | 33 | 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 | ['TypeScript'] | 0 |
max-increase-to-keep-city-skyline | [C++/Java/Python] Easy and Concise Solution | cjavapython-easy-and-concise-solution-by-z94u | Idea:\nFor grid[i][j], it can\'t be higher than the maximun of its row nor the maximum of its col.\nSo the maximum increasing height for a building at (i, j) is | lee215 | NORMAL | 2018-03-25T03:19:22.654182+00:00 | 2018-10-26T21:40:04.551439+00:00 | 25,158 | false | **Idea:**\nFor ```grid[i][j]```, it can\'t be higher than the maximun of its row nor the maximum of its col.\nSo the maximum increasing height for a building at ```(i, j)``` is ```min(row[i], col[j]) - grid[i][j]```\n\n**Codes:**\n```row```: maximum for every row\n```col```: maximum for every col\nThe fisrt loop of gri... | 201 | 0 | [] | 37 |
max-increase-to-keep-city-skyline | Python solution - Easy, fast, with comments | python-solution-easy-fast-with-comments-1jjjx | python\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:\n \n N = len(grid) # Height\n M = len | vvenzin | NORMAL | 2019-06-03T19:18:08.360288+00:00 | 2019-06-03T19:18:08.360334+00:00 | 2,646 | false | ```python\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:\n \n N = len(grid) # Height\n M = len(grid[0]) # Width\n \n # Transpose grid: Interchange rows and columns\n grid_t = zip(*grid)\n \n # Vertical and... | 22 | 0 | ['Python'] | 6 |
max-increase-to-keep-city-skyline | C++ Simple and Short Solution, Faster than 98% | c-simple-and-short-solution-faster-than-uu294 | \nclass Solution {\npublic:\n int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n int n = grid.size(), res = 0;\n vector<int> rows(n), | yehudisk | NORMAL | 2021-07-25T14:14:20.132638+00:00 | 2021-07-25T14:14:20.132679+00:00 | 2,120 | false | ```\nclass Solution {\npublic:\n int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n int n = grid.size(), res = 0;\n vector<int> rows(n), cols(n);\n \n for (int i = 0; i < n; i++) {\n for (int j = 0; j < n; j++) {\n rows[i] = max(rows[i], grid[i][j]);\n ... | 16 | 0 | ['C'] | 4 |
max-increase-to-keep-city-skyline | Python 3 (two lines) (beats ~100%) | python-3-two-lines-beats-100-by-junaidma-ilv8 | ```\nclass Solution:\n def maxIncreaseKeepingSkyline(self, G: List[List[int]]) -> int:\n M, N, R, C = len(G), len(G[0]), [max(r) for r in G], [max(c) | junaidmansuri | NORMAL | 2019-12-07T08:09:25.459478+00:00 | 2019-12-07T08:11:23.231434+00:00 | 1,774 | false | ```\nclass Solution:\n def maxIncreaseKeepingSkyline(self, G: List[List[int]]) -> int:\n M, N, R, C = len(G), len(G[0]), [max(r) for r in G], [max(c) for c in zip(*G)]\n return sum(min(R[i],C[j]) - G[i][j] for i,j in itertools.product(range(M),range(N)))\n\t\t\n\t\t\n- Junaid Mansuri\n- Chicago, IL | 15 | 8 | ['Python', 'Python3'] | 2 |
max-increase-to-keep-city-skyline | Beginner Friendly Easy Approach || Beats Everyone(100%) || All Popular Languages | beginner-friendly-easy-approach-beats-ev-10to | \n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nStore maximum of each row and column\n\n# Approach\n Describe your approach to so | Garv_Virmani | NORMAL | 2024-05-29T09:33:50.540617+00:00 | 2024-05-29T09:35:16.992938+00:00 | 611 | false | \n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nStore maximum of each row and column\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nGREEDY\n# C... | 12 | 0 | ['Array', 'Greedy', 'C', 'Matrix', 'Python', 'C++', 'Java', 'Python3', 'Ruby', 'JavaScript'] | 0 |
max-increase-to-keep-city-skyline | easiest solution || c++ || easy to understand || just simplest approach 🤔🤔 | easiest-solution-c-easy-to-understand-ju-9i09 | 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 | youdontknow001 | NORMAL | 2022-11-26T17:30:23.019243+00:00 | 2022-11-26T17:30:23.019285+00:00 | 885 | 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 | ['C++'] | 1 |
max-increase-to-keep-city-skyline | Functional JavaScript | functional-javascript-by-chrisrocco-lmh8 | ```\ntranspose = m => m[0].map((x,i) => m.map(x => x[i]))\n\nvar maxIncreaseKeepingSkyline = function(grid) {\n let rowMaxes = grid.map( row => Math.max(...r | chrisrocco | NORMAL | 2018-03-25T17:58:46.349499+00:00 | 2018-03-25T17:58:46.349499+00:00 | 1,228 | false | ```\ntranspose = m => m[0].map((x,i) => m.map(x => x[i]))\n\nvar maxIncreaseKeepingSkyline = function(grid) {\n let rowMaxes = grid.map( row => Math.max(...row))\n let colMaxes = transpose(grid).map( row => Math.max(...row))\n \n let increase = 0;\n for(let i = 0; i < grid.length; i++) {\n for(let... | 10 | 1 | [] | 4 |
max-increase-to-keep-city-skyline | Simple Python solution | simple-python-solution-by-cubicon-mkzn | \n def maxIncreaseKeepingSkyline(self, grid):\n rows_max = [0] * len(grid)\n cols_max = [0] * len(grid[0])\n\n for i in range(len(grid)) | Cubicon | NORMAL | 2018-03-25T03:01:37.963890+00:00 | 2018-09-19T23:10:33.725864+00:00 | 1,499 | false | ```\n def maxIncreaseKeepingSkyline(self, grid):\n rows_max = [0] * len(grid)\n cols_max = [0] * len(grid[0])\n\n for i in range(len(grid)):\n for j in range(len(grid[0])):\n rows_max[i] = max(rows_max[i], grid[i][j])\n cols_max[j] = max(cols_max[j], grid... | 10 | 0 | [] | 0 |
max-increase-to-keep-city-skyline | 0ms JAVA | 98.98% faster & 100% memory | 0ms-java-9898-faster-100-memory-by-onefi-r4u4 | \nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n if(grid == null)\n return 0;\n int n = grid.length;\n | onefineday01 | NORMAL | 2020-04-19T19:29:50.510992+00:00 | 2020-04-19T19:30:53.835828+00:00 | 1,595 | false | ```\nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n if(grid == null)\n return 0;\n int n = grid.length;\n int m = grid[0].length;\n int maxrow[] = new int[n];\n int maxcol[] = new int[m];\n for(int i = 0; i < n; i++)\n for(int... | 8 | 0 | ['Java'] | 1 |
max-increase-to-keep-city-skyline | C++, Straightforward O(m*n) time | c-straightforward-omn-time-by-ddev-53oh | int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n vector<int> row_max(grid.size(), INT_MIN);\n vector<int> col_max(grid.size() ? grid[0 | ddev | NORMAL | 2018-03-25T03:15:29.792564+00:00 | 2018-03-25T03:15:29.792564+00:00 | 2,211 | false | int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n vector<int> row_max(grid.size(), INT_MIN);\n vector<int> col_max(grid.size() ? grid[0].size() : 0, INT_MIN);\n int result = 0;\n \n for(int i = 0 ; i < grid.size(); i++) {\n for(int j = 0; j < grid[0].size(); ... | 7 | 1 | [] | 4 |
max-increase-to-keep-city-skyline | C++ simple solution 8 ms | c-simple-solution-8-ms-by-oleksam-o37p | \n// Please, UpVote, if you like it :-)\nint maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n\tint maxIncrease = 0, rows = grid.size(), cols = grid[0].s | oleksam | NORMAL | 2021-01-24T17:15:56.033071+00:00 | 2021-01-24T17:22:04.667655+00:00 | 606 | false | ```\n// Please, UpVote, if you like it :-)\nint maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n\tint maxIncrease = 0, rows = grid.size(), cols = grid[0].size();\n\tvector<int> rowMax(rows, 0);\n\tvector<int> colsMax(cols, 0);\n\tfor (int i = 0; i < rows; i++) {\n\t\tfor (int j = 0; j < cols; j++) {\n\t\t\trowM... | 6 | 1 | ['C', 'C++'] | 0 |
max-increase-to-keep-city-skyline | 48ms Python3 solution | 48ms-python3-solution-by-vanden-qn28 | To my surprise (I am not a speed demon), this was deemed faster than 100% of Py3 submissions:\n\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid): | vanden | NORMAL | 2018-04-23T18:15:30.721671+00:00 | 2018-08-13T19:15:14.368004+00:00 | 2,166 | false | To my surprise (I am not a speed demon), this was deemed faster than 100% of Py3 submissions:\n```\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid):\n """\n :type grid: List[List[int]]\n :rtype: int\n """\n row_maxes = [max(row) for row in grid]\n\n col_maxes = [... | 6 | 0 | [] | 3 |
max-increase-to-keep-city-skyline | Concise Python Solution | concise-python-solution-by-szhi-dx4j | ``` \n\t\tlenth = len(grid)\n hhigh = [max(row) for row in grid]\n vhigh = [max(col) for col in zip(*grid)]\n ans = 0\n for i | szhi | NORMAL | 2019-08-27T19:52:28.679606+00:00 | 2019-08-27T19:52:28.679640+00:00 | 386 | false | ``` \n\t\tlenth = len(grid)\n hhigh = [max(row) for row in grid]\n vhigh = [max(col) for col in zip(*grid)]\n ans = 0\n for i in range(lenth):\n for j in range(lenth):\n ans+=(min(hhigh[i],vhigh[j]) - grid[i][j])\n return(ans)\n | 5 | 0 | [] | 0 |
max-increase-to-keep-city-skyline | Beats 100% and easy to understand... | beats-100-and-easy-to-understand-by-krus-vwmi | Intuition : Calculate Row max and Column max, compare.\n Describe your first thoughts on how to solve this problem. \n\n# Approach : Row max & Column max.\n Des | Krushna_Yeshwante | NORMAL | 2024-09-18T13:09:33.858076+00:00 | 2024-09-18T13:09:33.858106+00:00 | 190 | false | # Intuition : Calculate Row max and Column max, compare.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach : Row max & Column max.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity : O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\... | 4 | 0 | ['Array', 'Greedy', 'Matrix', 'Java'] | 0 |
max-increase-to-keep-city-skyline | easy C++ solution,98% time 80% memory | easy-c-solution98-time-80-memory-by-shub-lcrv | Intuition\nstore each row max element a "rowmax" vector and each column max element in "colmax" vector;\n Describe your first thoughts on how to solve this prob | shubhamo7 | NORMAL | 2023-04-28T14:02:42.887662+00:00 | 2023-04-28T14:02:42.887690+00:00 | 419 | false | # Intuition\nstore each row max element a "rowmax" vector and each column max element in "colmax" vector;\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n-> create two vectors to store each row max element and each column max element.\n-> store max element of row 0 in 0th index of "r... | 4 | 0 | ['C++'] | 0 |
max-increase-to-keep-city-skyline | ✅ JavaScript - explanation | javascript-explanation-by-daria_abdulnas-tlpv | Approach\n Describe your approach to solving the problem. \nAt first, we count the maximum height of buildings in rows and columns, keep it in rMax and cMax. Yo | daria_abdulnasyrova | NORMAL | 2023-03-28T07:21:08.179370+00:00 | 2023-03-29T08:12:11.967371+00:00 | 173 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nAt first, we count the maximum height of buildings in rows and columns, keep it in `rMax` and `cMax`. You can imagine that `rMax` is a city\'s skyline if you look at the city from East or West (they are the same as it is projection) and `cMax` is a ci... | 4 | 0 | ['JavaScript'] | 0 |
max-increase-to-keep-city-skyline | Easy c++ solution with explanation. | easy-c-solution-with-explanation-by-luff-gb79 | Intuition\nHeight of any building can only be raised to the of the maximum height building in the same column and same row as aforementioned building.\n\n# Appr | luffy0908 | NORMAL | 2023-03-24T16:21:46.902087+00:00 | 2023-03-24T16:21:46.902179+00:00 | 790 | false | # Intuition\nHeight of any building can only be raised to the of the maximum height building in the same column and same row as aforementioned building.\n\n# Approach\nMake 2 vectors where you can store the maximum height in a given row and column. Since we are asked not to change the skyline from any cardinal directio... | 4 | 0 | ['C++'] | 0 |
max-increase-to-keep-city-skyline | Solution in C++ | solution-in-c-by-ashish_madhup-fa38 | 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 | ashish_madhup | NORMAL | 2023-02-25T10:34:42.863269+00:00 | 2023-02-25T10:34:42.863317+00:00 | 548 | 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)$$ --... | 4 | 0 | ['C++'] | 1 |
max-increase-to-keep-city-skyline | [PYTHON 3] EASY | SIMPLE SOLUTION | STRAIGHT FORWARD | python-3-easy-simple-solution-straight-f-uaa2 | ```\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:\n rows_max = [0] * len(grid)\n cols_max = [0] * len(g | omkarxpatel | NORMAL | 2022-07-12T00:55:40.562554+00:00 | 2022-07-12T00:55:40.562594+00:00 | 1,148 | false | ```\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:\n rows_max = [0] * len(grid)\n cols_max = [0] * len(grid[0])\n\n for i in range(len(grid)):\n for j in range(len(grid[0])):\n rows_max[i] = max(rows_max[i], grid[i][j])\n ... | 4 | 0 | ['Python', 'Python3'] | 0 |
max-increase-to-keep-city-skyline | 🥟 C++ || EASY SOL WITH YT LINK EXPLANATION | c-easy-sol-with-yt-link-explanation-by-v-b7xk | \n\n\t\tclass Solution {\n\t\tpublic:\n\t\t\tint maxIncreaseKeepingSkyline(vector>& grid) {\n\t\t\t\tint n = grid.size(), ans = 0;\n\t\t\t\tvector rows(n);\n\t\ | venom-xd | NORMAL | 2022-04-21T16:38:15.216405+00:00 | 2022-04-21T16:38:15.216448+00:00 | 420 | false | \n\n\t\tclass Solution {\n\t\tpublic:\n\t\t\tint maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n\t\t\t\tint n = grid.size(), ans = 0;\n\t\t\t\tvector<int> rows(n);\n\t\t\t\tvector<int> cols(n);\n\n\t\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\t\t\trows[i] = max(rows[i],... | 4 | 0 | ['C', 'C++'] | 0 |
max-increase-to-keep-city-skyline | Python | Easy | Straight Forward | Easy to Understand | python-easy-straight-forward-easy-to-und-idbn | Code\n\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:\n # get list of columns by transposing the matrix \n | RahulAnand28 | NORMAL | 2023-10-15T07:29:52.647136+00:00 | 2023-10-15T07:29:52.647153+00:00 | 86 | false | # Code\n```\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:\n # get list of columns by transposing the matrix \n col_lst = [list(col) for col in zip(*grid)]\n col_max = [max(i) for i in col_lst]\n row_max = [max(i) for i in grid]\n final_num = ... | 3 | 0 | ['Python3'] | 0 |
max-increase-to-keep-city-skyline | Easiest C++ | easiest-c-by-sparrow_harsh-q6h9 | Intuition\nWe can increase height of a cell to min(maximum of row, maximum of column).\n\n# Approach\nWe will find maximumn elements of all the rows and all the | sparrow_harsh | NORMAL | 2023-06-07T06:49:38.600951+00:00 | 2023-06-07T06:49:38.600999+00:00 | 298 | false | # Intuition\nWe can increase height of a cell to min(maximum of row, maximum of column).\n\n# Approach\nWe will find maximumn elements of all the rows and all the columns and store it into a vector.\n\nThen we will traverse through grid and find minimum of row and col say te. And then we will add abs(te- grid[i][j]) to... | 3 | 0 | ['Greedy', 'C++'] | 0 |
max-increase-to-keep-city-skyline | Easy python 5 liner solution solution 🔥🔥🔥🔥 | easy-python-5-liner-solution-solution-by-yfut | \n# Code\n\nclass Solution(object):\n def maxIncreaseKeepingSkyline(self, grid):\n """\n :type grid: List[List[int]]\n :rtype: int\n | Lalithkiran | NORMAL | 2023-03-19T05:28:13.776584+00:00 | 2023-03-19T05:28:13.776634+00:00 | 476 | false | \n# Code\n```\nclass Solution(object):\n def maxIncreaseKeepingSkyline(self, grid):\n """\n :type grid: List[List[int]]\n :rtype: int\n """\n sm=0\n lst=[max(i) ... | 3 | 0 | ['Array', 'Greedy', 'Matrix', 'Python'] | 0 |
max-increase-to-keep-city-skyline | Java Solution, beats 100% | java-solution-beats-100-by-theycallmepre-4bzc | Intuition\nContours are decided by the maximum heights, for north and south watchers, the buildings with max heights in each column and for east and west watche | TheyCallMePrem | NORMAL | 2023-01-08T18:31:53.926356+00:00 | 2023-01-08T18:31:53.926391+00:00 | 1,166 | false | # Intuition\nContours are decided by the maximum heights, for north and south watchers, the buildings with max heights in each column and for east and west watchers, max heights in each row. \n\n# Approach\nIterate over grid[][] to find maximum elements of each row and each column, the any element in updated grid[][], ... | 3 | 0 | ['Java'] | 3 |
max-increase-to-keep-city-skyline | Detailed Explanation || CPP || DP | detailed-explanation-cpp-dp-by-sansk_rit-px6q | Intuition\nBy looking at the problem, we understand that the tallest building in that row from that direction is the one contributing to the skyline of that dir | Sansk_Ritu | NORMAL | 2022-12-24T12:26:57.120274+00:00 | 2022-12-24T12:26:57.120302+00:00 | 100 | false | # Intuition\nBy looking at the problem, we understand that the tallest building in that row from that direction is the one contributing to the skyline of that direction\nSuppose you are looking from the bottom (South) then for the grid[0][j]] the tallest building in jth column will be considered for answer\n\n# Approac... | 3 | 0 | ['Hash Table', 'Dynamic Programming', 'Greedy', 'C++'] | 0 |
max-increase-to-keep-city-skyline | Java Easy and fast | java-easy-and-fast-by-htksaurav-uufo | \nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n int []row = new int[grid.length];\n int []column = new int[grid[0]. | htksaurav | NORMAL | 2022-03-29T17:14:39.852408+00:00 | 2022-03-29T17:14:39.852488+00:00 | 351 | false | ```\nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n int []row = new int[grid.length];\n int []column = new int[grid[0].length];\n \n for(int i=0;i<grid.length;i++){\n int maxRow = 0;\n int maxColumn = 0;\n for(int j=0;j<grid[i].l... | 3 | 0 | ['Java'] | 0 |
max-increase-to-keep-city-skyline | [Python3] max per row & column | python3-max-per-row-column-by-ye15-l3j6 | Algo \nThe maximum increase in height at i, j is the difference between the minimum of max of row i and max of col j and grid[i][j]. \n\nImplementation \n\nclas | ye15 | NORMAL | 2020-11-12T03:50:37.454831+00:00 | 2020-11-12T03:50:37.454876+00:00 | 329 | false | Algo \nThe maximum increase in height at `i, j` is the difference between the minimum of max of row `i` and max of col `j` and `grid[i][j]`. \n\nImplementation \n```\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:\n m, n = len(grid), len(grid[0])\n row = [max(x) fo... | 3 | 0 | ['Python3'] | 0 |
max-increase-to-keep-city-skyline | Clear, Understandable Solution using Map and Meaningful Variables (~90% Speed, 50% Memory) O(n^2) | clear-understandable-solution-using-map-3k8id | ```\n/*\nTo maximize the height while maintaining the height of the skyline from the view of the top/botttom and right/left:\n GOAL: At every A[row][col] we | masterofnone | NORMAL | 2019-11-11T14:43:08.678852+00:00 | 2019-11-11T17:30:13.122431+00:00 | 559 | false | ```\n/**\nTo maximize the height while maintaining the height of the skyline from the view of the top/botttom and right/left:\n GOAL: At every A[row][col] we need to find the max of that row, column, and then make the current A[i][j] = the minimum of the two, as long as it\'s greater than the current value\n 1) M... | 3 | 0 | ['JavaScript'] | 0 |
max-increase-to-keep-city-skyline | Done but I need to understand the problem ka description 😅 :D | done-but-i-need-to-understand-the-proble-k3or | 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 | yesyesem | NORMAL | 2024-10-12T18:49:57.014766+00:00 | 2024-10-12T18:49:57.014790+00:00 | 91 | 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 | ['C++'] | 0 |
max-increase-to-keep-city-skyline | Beats 100% and easy to understand... | beats-100-and-easy-to-understand-by-anik-qamb | Intuition : Calculate Row max and Column max, compare.\n Describe your first thoughts on how to solve this problem. \n\n# Approach : Row max & Column max.\n Des | Aniket16903 | NORMAL | 2024-09-18T13:09:30.402540+00:00 | 2024-09-18T13:09:30.402573+00:00 | 46 | false | # Intuition : Calculate Row max and Column max, compare.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach : Row max & Column max.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity : O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\... | 2 | 0 | ['Array', 'Greedy', 'Matrix', 'Java'] | 0 |
max-increase-to-keep-city-skyline | Best Java Solution || Beats 100% | best-java-solution-beats-100-by-ravikuma-clz2 | 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 | ravikumar50 | NORMAL | 2023-09-10T09:23:11.268816+00:00 | 2023-09-10T09:23:11.268833+00:00 | 135 | 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 | ['Java'] | 0 |
max-increase-to-keep-city-skyline | python3 solution using 2 arrays beats 98% O(N) space | python3-solution-using-2-arrays-beats-98-lbgj | Intuition\n Describe your first thoughts on how to solve this problem. \nhere a contains maximum in each row\nhere b cointains maximum in each column\nc has max | Sumukha_g | NORMAL | 2023-08-03T13:34:38.550945+00:00 | 2023-08-03T13:34:38.550979+00:00 | 421 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nhere a contains maximum in each row\nhere b cointains maximum in each column\nc has max in each column which will be appendded to b\nafter having these we just just need to compare a[i] and b[j] whichever is lower to maintain skyline and ... | 2 | 0 | ['Array', 'Matrix', 'Python3'] | 0 |
max-increase-to-keep-city-skyline | Simple C++ Solution | Intuitive | Beginner-Friendly Explanation | simple-c-solution-intuitive-beginner-fri-ix10 | Intuition\nThe primary thing to understand here is that we do not need to take all four points of view into consideration. If you observe carefully, the skyline | Anuvab | NORMAL | 2023-08-02T19:52:50.859778+00:00 | 2023-08-12T06:14:04.797707+00:00 | 23 | false | # Intuition\nThe primary thing to understand here is that we do not need to take all four points of view into consideration. If you observe carefully, the skyline view from the $$North(N)$$ side and the skyline view from the $$South(S)$$ side are simply reversed because it is the same skyline. It is like the viewing th... | 2 | 0 | ['Array', 'Matrix', 'C++'] | 0 |
max-increase-to-keep-city-skyline | ✅Easy C++ code using for loop || BEGINNER FRIENDLY | easy-c-code-using-for-loop-beginner-frie-vdis | 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 | vishu_0123 | NORMAL | 2023-02-26T09:33:44.589219+00:00 | 2023-02-26T09:38:46.677231+00:00 | 238 | 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 | ['C++'] | 0 |
max-increase-to-keep-city-skyline | CPP SOLUTION || EASY TO UNDERSTAND || SIMPLE AND CLEAN CODE | cpp-solution-easy-to-understand-simple-a-dft5 | \n\n# Code\n\nclass Solution {\n int n;\n int skyline(vector<vector<int>>& v,int r,int c){\n int h1 = -1e9,h2=-1e9;\n for(int i =0;i<n;++i){ | msdarshan | NORMAL | 2023-02-13T17:58:01.893115+00:00 | 2023-02-13T17:58:01.893160+00:00 | 28 | false | \n\n# Code\n```\nclass Solution {\n int n;\n int skyline(vector<vector<int>>& v,int r,int c){\n int h1 = -1e9,h2=-1e9;\n for(int i =0;i<n;++i){\n h1 = max(h1,v[r][i]);\n h2 = max(h2,v[i][c]);\n }\n return min(h1,h2);\n }\npublic:\n int maxIncreaseKeepingSkyl... | 2 | 0 | ['C++'] | 0 |
max-increase-to-keep-city-skyline | 📌 c++ solution | store max from left view and top view ✔ | c-solution-store-max-from-left-view-and-yq5mu | \nclass Solution {\npublic:\n int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n vector<int> top, left;\n int ln= grid.size();\n | 1911Uttam | NORMAL | 2023-02-10T13:36:06.106039+00:00 | 2023-02-10T13:36:06.106094+00:00 | 249 | false | ```\nclass Solution {\npublic:\n int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n vector<int> top, left;\n int ln= grid.size();\n \n for(auto &x:grid){\n left.push_back(*max_element(x.begin(), x.begin()+ln));\n }\n \n for(int j=0;j<ln;j++){\n ... | 2 | 0 | ['C', 'C++'] | 0 |
max-increase-to-keep-city-skyline | Easy C++ traversal O(NxN) solution | easy-c-traversal-onxn-solution-by-shrist-mwi3 | \n# Code\n\nclass Solution {\npublic:\n int findMax(vector<int>arr){\n int maxi=arr[0];\n for(int i=1;i<arr.size();i++){\n if(arr[i] | Shristha | NORMAL | 2023-01-11T13:00:22.075531+00:00 | 2023-01-11T13:00:22.075577+00:00 | 690 | false | \n# Code\n```\nclass Solution {\npublic:\n int findMax(vector<int>arr){\n int maxi=arr[0];\n for(int i=1;i<arr.size();i++){\n if(arr[i]>maxi){\n maxi=arr[i];\n }\n }\n return maxi;\n }\n int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\... | 2 | 0 | ['C++'] | 0 |
max-increase-to-keep-city-skyline | 0ms beats 100% Super readable code with comments | 0ms-beats-100-super-readable-code-with-c-wqyl | Intuition\n Describe your first thoughts on how to solve this problem. \nThis shit is super difficult i will never be able to solve this but i\'ll try anyways.\ | tdf56f756bg56r8iohgwexu | NORMAL | 2023-01-03T01:34:50.340161+00:00 | 2023-01-03T01:34:50.340196+00:00 | 645 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis shit is super difficult i will never be able to solve this but i\'ll try anyways.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nA skyline is defined by the highest buildings in a collumn or row.\n\nIf i keep t... | 2 | 0 | ['Rust'] | 0 |
max-increase-to-keep-city-skyline | Easy Java Solution | easy-java-solution-by-mandarin_075-aguf | \n# Complexity\n- Time complexity: O(n^2)\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 | mandarin_075 | NORMAL | 2022-12-10T04:11:56.788437+00:00 | 2022-12-10T04:11:56.788479+00:00 | 274 | false | \n# Complexity\n- Time complexity: O(n^2)\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 {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n int sum=0;\n int n=grid.length;\... | 2 | 0 | ['Java'] | 0 |
max-increase-to-keep-city-skyline | C++ solution | c-solution-by-_kitish-6b4q | Intuition\nWe can find the maximum of all the row and column and keep on subtracting the minminum of both rowmax and colmax.\n\n# Approach\nStore the minimum of | _kitish | NORMAL | 2022-12-06T17:09:41.320823+00:00 | 2022-12-06T17:09:41.320897+00:00 | 920 | false | # Intuition\nWe can find the maximum of all the row and column and keep on subtracting the minminum of both rowmax and colmax.\n\n# Approach\nStore the minimum of row and col in vector<pair<int,int>> and keep on subtracting the minimum of rowmax and colmax from each element because we\'ve to maintain the skyline.\n\n# ... | 2 | 0 | ['Array', 'Greedy', 'C++'] | 0 |
max-increase-to-keep-city-skyline | java Clear Solution | java-clear-solution-by-solver_ss-9cpw | Code\n\nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n int sum =0;\n for (int i = 0 ;i< grid.length;i++){\n | Solver_sS | NORMAL | 2022-12-03T12:24:16.884326+00:00 | 2022-12-03T12:24:16.884365+00:00 | 434 | false | # Code\n```\nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n int sum =0;\n for (int i = 0 ;i< grid.length;i++){\n for (int j =0 ;j<grid[i].length;j++){\n int old = grid[i][j];\n grid[i][j] = Math.min(rowMax(grid[i]),colMax(grid, j));\n ... | 2 | 0 | ['Java'] | 0 |
max-increase-to-keep-city-skyline | easy java solution | easy-java-solution-by-viveksharma10-nj0q | \nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] g) {\n int[][] p=new int[g.length][2];\n int m=0;\n for(int i=0;i<g.len | viveksharma10 | NORMAL | 2022-10-04T20:28:03.585739+00:00 | 2022-10-04T20:28:03.585780+00:00 | 17 | false | ```\nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] g) {\n int[][] p=new int[g.length][2];\n int m=0;\n for(int i=0;i<g.length;i++)\n { \n m=g[i][0];\n for(int j=1;j<g.length;j++)\n {\n if(m<g[i][j])\n m=g[i][j];... | 2 | 0 | ['Java'] | 0 |
max-increase-to-keep-city-skyline | Java Solution 0ms runtime and faster than 100% with 4 points explanation. | java-solution-0ms-runtime-and-faster-tha-jyhu | \n// Max Increase to Keep City Skyline\n// https://leetcode.com/problems/max-increase-to-keep-city-skyline/\n\nclass Solution {\n public int maxIncreaseKeepi | aayushkumar20 | NORMAL | 2022-05-29T05:37:54.243454+00:00 | 2022-05-29T05:37:54.243498+00:00 | 201 | false | ```\n// Max Increase to Keep City Skyline\n// https://leetcode.com/problems/max-increase-to-keep-city-skyline/\n\nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n int[] rowMax = new int[grid.length];\n int[] colMax = new int[grid[0].length];\n for (int i = 0; i < grid.le... | 2 | 0 | ['Java'] | 0 |
max-increase-to-keep-city-skyline | Java Easy Understsnding Self Expalantory | java-easy-understsnding-self-expalantory-b7cg | \nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n List<Integer> rowMax = new ArrayList<>();\n List<Integer> colMax = | bharat194 | NORMAL | 2022-04-10T14:48:13.485565+00:00 | 2022-04-10T14:48:13.485608+00:00 | 174 | false | ```\nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n List<Integer> rowMax = new ArrayList<>();\n List<Integer> colMax = new ArrayList<>();\n for(int i=0;i<grid.length;i++){\n int[] max = max(grid,i,i);\n rowMax.add(max[0]);\n colMax.add(... | 2 | 0 | ['Java'] | 0 |
max-increase-to-keep-city-skyline | C++ easy approach with explanation | c-easy-approach-with-explanation-by-shar-0ai8 | It is a simple problem with tricky question.\n\n*******************************************EXPLANATION******************************************************\n\n | sharathkumarKA | NORMAL | 2022-02-28T06:10:44.642939+00:00 | 2022-02-28T06:24:31.248956+00:00 | 75 | false | It is a simple problem with tricky question.\n``` \n*******************************************EXPLANATION******************************************************\n\n Max row\n 3 0 8 4 8\n 2 4 5 7 7\n 9 2 6 ... | 2 | 0 | [] | 0 |
max-increase-to-keep-city-skyline | [C++] simple solution | c-simple-solution-by-tinfu330-bhgc | \nclass Solution {\npublic:\n int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n int n = grid.size();\n \n vector<int> rMax (n | tinfu330 | NORMAL | 2022-01-24T06:40:02.103821+00:00 | 2022-01-24T06:40:02.103854+00:00 | 117 | false | ```\nclass Solution {\npublic:\n int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n int n = grid.size();\n \n vector<int> rMax (n, INT_MIN);\n vector<int> cMax (n, INT_MIN);\n \n for (int r = 0; r < n; r++) {\n for (int c = 0; c < n; c++) {\n ... | 2 | 0 | ['C', 'C++'] | 0 |
max-increase-to-keep-city-skyline | EASY C++ SOLUTION | FASTER THAN 97.85% | easy-c-solution-faster-than-9785-by-kary-cmd1 | \nclass Solution {\npublic:\n int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n int n = grid.size(), ans = 0;\n vector<int> r(n), c( | karygauss03 | NORMAL | 2021-08-03T19:52:04.917165+00:00 | 2021-08-03T19:52:04.917225+00:00 | 77 | false | ```\nclass Solution {\npublic:\n int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n int n = grid.size(), ans = 0;\n vector<int> r(n), c(n);\n \n for (int i = 0 ; i < n ; i++){\n for (int j = 0 ; j < n ; j++){\n r[i] = max(r[i], grid[i][j]);\n ... | 2 | 0 | [] | 0 |
max-increase-to-keep-city-skyline | C++ | c-by-harshattree-9d7j | \nint maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n vector<int> N;\n vector<int> E;\n \n int a;\n int ans=0;\n | HarshAttree | NORMAL | 2021-07-19T06:25:43.377982+00:00 | 2021-07-19T06:25:43.378025+00:00 | 59 | false | ```\nint maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n vector<int> N;\n vector<int> E;\n \n int a;\n int ans=0;\n int max=0;\n int b;\n for(int i=0;i<grid.size();i++){\n max=0;\n for(int j=0;j<grid.size();j++){\n if(... | 2 | 0 | [] | 0 |
max-increase-to-keep-city-skyline | C++ 97% FASTER EASY SOLUTION | c-97-faster-easy-solution-by-amitsaxena0-13dd | Find maximum heights row wise and column wise, then take minimum of both and find the difference with each block\'s heights:\n\n\n int maxIncreaseKeepingSkyline | amitsaxena098 | NORMAL | 2021-07-02T06:35:12.196595+00:00 | 2021-07-02T06:35:12.196638+00:00 | 116 | false | Find maximum heights row wise and column wise, then take minimum of both and find the difference with each block\'s heights:\n\n```\n int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n \n vector<int> maxHeightsRow(grid.size(),0);\n vector<int> maxHeightsCol(grid[0].size(), 0);\n \n... | 2 | 0 | [] | 1 |
max-increase-to-keep-city-skyline | [Python] Solution beats 99.45% | python-solution-beats-9945-by-dexderp1-s94v | \n\n def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int\n\t cols = list(zip(*grid))\n rowMaxes = [ max(row) for row in grid ]\n | dexderp1 | NORMAL | 2019-12-19T02:49:33.796980+00:00 | 2019-12-19T02:49:33.797016+00:00 | 236 | false | \n\n def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int\n\t cols = list(zip(*grid))\n rowMaxes = [ max(row) for row in grid ]\n colMaxes = [ max(col) for col in cols ]\n \n maxIncrease = 0\n for i in range(len(grid)):\n for j in range(len(grid[0])):\n ... | 2 | 0 | [] | 0 |
max-increase-to-keep-city-skyline | scala functional solution | scala-functional-solution-by-gyarish-wad2 | \nobject Solution {\n def maxIncreaseKeepingSkyline(grid: Array[Array[Int]]): Int = {\n \n val skyLineTop = grid.map(row => row.max)\n v | gyarish | NORMAL | 2019-11-09T12:16:20.148574+00:00 | 2019-11-09T12:16:20.148608+00:00 | 71 | false | ```\nobject Solution {\n def maxIncreaseKeepingSkyline(grid: Array[Array[Int]]): Int = {\n \n val skyLineTop = grid.map(row => row.max)\n val skyLineLeft = grid.transpose.map(row => row.max)\n \n val seq = for {\n i <- grid.indices\n j <- grid(i).indices\n ... | 2 | 0 | ['Scala'] | 0 |
max-increase-to-keep-city-skyline | Python Numpy Implementation | python-numpy-implementation-by-msminhas-ai71 | \n\nimport numpy as np\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:\n argrid = np.array(grid)\n tbsky | msminhas | NORMAL | 2019-09-30T18:45:14.966510+00:00 | 2019-09-30T18:45:14.966563+00:00 | 183 | false | \n```\nimport numpy as np\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:\n argrid = np.array(grid)\n tbsky = np.max(argrid,axis=0)\n lrsky = np.max(argrid,axis=1)\n mesh = np.meshgrid(tbsky,lrsky)\n maxmesh = np.min(mesh,axis=0)\n incr... | 2 | 0 | [] | 1 |
max-increase-to-keep-city-skyline | [Java] O(n) solution beats 100% | java-on-solution-beats-100-by-olsh-9lcd | \nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n int[] horizontal = new int[grid[0].length];\n int[] vertical = new | olsh | NORMAL | 2019-07-08T20:51:49.746870+00:00 | 2019-07-09T09:39:34.845218+00:00 | 694 | false | ```\nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n int[] horizontal = new int[grid[0].length];\n int[] vertical = new int[grid.length];\n for (int i=0;i<grid.length;i++){\n for (int j=0;j<grid[0].length;j++){\n horizontal[j]=Math.max(horizont... | 2 | 1 | [] | 3 |
max-increase-to-keep-city-skyline | Python 24ms Code | python-24ms-code-by-dacheng0413-u9pz | \nclass Solution(object):\n def maxIncreaseKeepingSkyline(self, grid):\n """\n :type grid: List[List[int]]\n :rtype: int\n """\n | dacheng0413 | NORMAL | 2019-02-15T04:42:39.536623+00:00 | 2019-02-15T04:42:39.536672+00:00 | 519 | false | ```\nclass Solution(object):\n def maxIncreaseKeepingSkyline(self, grid):\n """\n :type grid: List[List[int]]\n :rtype: int\n """\n top_max=[]\n left_max=[]\n for i in range(len(grid)):\n left_max.append(max(grid[i]))\n for i in range(len(grid[0])):\... | 2 | 0 | ['Python'] | 1 |
max-increase-to-keep-city-skyline | Simple Python Solution | simple-python-solution-by-ciufi23-x9zp | \nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid):\n """\n :type grid: List[List[int]]\n :rtype: int\n """\n t | ciufi23 | NORMAL | 2019-01-09T15:56:37.286594+00:00 | 2019-01-09T15:56:37.286636+00:00 | 198 | false | ```\nclass Solution:\n def maxIncreaseKeepingSkyline(self, grid):\n """\n :type grid: List[List[int]]\n :rtype: int\n """\n total = 0\n N = len(grid)\n \n # Can also do this by iterating once through the matrix\n max_row = [max(row) for row in grid]\n ... | 2 | 0 | [] | 1 |
max-increase-to-keep-city-skyline | Rust Solution, 0ms | rust-solution-0ms-by-terakilobyte-z6mj | \nimpl Solution {\n pub fn max_increase_keeping_skyline(grid: Vec<Vec<i32>>) -> i32 {\n let mut row_maxes: Vec<i32> = (0..grid.len()).into_iter().map( | terakilobyte | NORMAL | 2019-01-04T13:54:54.081000+00:00 | 2019-01-04T13:54:54.081044+00:00 | 113 | false | ```\nimpl Solution {\n pub fn max_increase_keeping_skyline(grid: Vec<Vec<i32>>) -> i32 {\n let mut row_maxes: Vec<i32> = (0..grid.len()).into_iter().map(|_| 0).collect();\n let mut col_maxes: Vec<i32> = (0..grid[0].len()).into_iter().map(|_| 0).collect();\n for i in 0..grid.len() {\n ... | 2 | 0 | [] | 1 |
max-increase-to-keep-city-skyline | Python solution | python-solution-by-zitaowang-ye9w | \nclass Solution(object):\n def maxIncreaseKeepingSkyline(self, grid):\n """\n :type grid: List[List[int]]\n :rtype: int\n """\n | zitaowang | NORMAL | 2018-08-30T01:05:40.425486+00:00 | 2018-08-30T01:05:40.425566+00:00 | 297 | false | ```\nclass Solution(object):\n def maxIncreaseKeepingSkyline(self, grid):\n """\n :type grid: List[List[int]]\n :rtype: int\n """\n rowNum = len(grid)\n colNum = len(grid[0])\n rowMax = [max(grid[i]) for i in range(rowNum)]\n colMax = [max([grid[j][i] for j in ... | 2 | 0 | [] | 0 |
max-increase-to-keep-city-skyline | javascript ES6 step by step 60 ms | javascript-es6-step-by-step-60-ms-by-flo-khvy | \nconst maxIncreaseKeepingSkyline = (grid) => {\n let rowMaxes = [];\n let colMaxes = [];\n \n // max each row\n grid.map(row => rowMaxes.push(Ma | flo92105 | NORMAL | 2018-05-18T22:26:09.815312+00:00 | 2018-05-18T22:26:09.815312+00:00 | 325 | false | ```\nconst maxIncreaseKeepingSkyline = (grid) => {\n let rowMaxes = [];\n let colMaxes = [];\n \n // max each row\n grid.map(row => rowMaxes.push(Math.max(...row)));\n \n // transpose from stackoverflow\n const transposedGrid = grid[0].map((col, i) => grid.map(row => row[i]));\n // max each c... | 2 | 1 | [] | 0 |
max-increase-to-keep-city-skyline | Greedy | greedy-by-akshaypatidar33-xsly | Code | akshaypatidar33 | NORMAL | 2025-04-10T18:54:24.607352+00:00 | 2025-04-10T18:54:24.607352+00:00 | 2 | false | # Code
```cpp []
class Solution {
public:
int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {
int n = grid.size();
vector<int> rmax(n);
vector<int> cmax(n);
for(int i=0; i<n; i++){
int mr = INT_MIN;
int mc = INT_MIN;
for(int j=0; j<n; j++){
... | 1 | 0 | ['Array', 'Greedy', 'Matrix', 'C++'] | 0 |
max-increase-to-keep-city-skyline | Beginner-Friendly Solution: Maximize Building Heights Without Changing Skyline | beginner-friendly-solution-maximize-buil-qzgg | ✅ IntuitionThe goal is to maximize the height of the buildings without changing the skyline. The skyline is defined by the max height in each row and column.🔥 A | vishwajeetwalekar037 | NORMAL | 2025-03-29T13:15:46.201766+00:00 | 2025-03-29T13:15:46.201766+00:00 | 15 | false | ### ✅ **Intuition**
The goal is to maximize the height of the buildings without changing the skyline. The skyline is defined by the max height in each row and column.
### 🔥 **Approach**
1. **Find Max Heights:**
- For each row, find the maximum height.
- For each column, find the maximum height.
2. **Calcu... | 1 | 0 | ['Java'] | 0 |
max-increase-to-keep-city-skyline | Easy solution using for loop|| Beats 100 % || JAVA | easy-solution-using-for-loop-beats-100-j-qt8i | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Rajan_Singh01 | NORMAL | 2025-03-24T15:39:39.427634+00:00 | 2025-03-24T15:39:39.427634+00:00 | 37 | 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', 'Greedy', 'Matrix', 'Java'] | 0 |
max-increase-to-keep-city-skyline | Easy Solution | easy-solution-by-harshulgarg-cqqn | IntuitionIncrease building heights while ensuring the skyline remains unchanged when viewed from the top and sides. The maximum possible height of each building | harshulgarg | NORMAL | 2025-01-31T19:47:13.547151+00:00 | 2025-01-31T19:47:13.547151+00:00 | 77 | false | # Intuition
Increase building heights while ensuring the skyline remains unchanged when viewed from the top and sides. The maximum possible height of each building is limited by the highest value in its row and column.
# Approach
Compute row-wise max (a[]) and column-wise max (b[]).
Calculate the original sum of all g... | 1 | 0 | ['Array', 'Python3'] | 0 |
max-increase-to-keep-city-skyline | C++ | 100% Faster | c-100-faster-by-user3219pp-0buu | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | user3219pp | NORMAL | 2025-01-26T19:24:58.664385+00:00 | 2025-01-26T19:24:58.664385+00:00 | 67 | 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 |
max-increase-to-keep-city-skyline | easy code | easy-code-by-red_viper-ieb3 | IntuitionApproachComplexity
Time complexity: O(N^ 2)
Space complexity: O(N)
Code | red_viper | NORMAL | 2025-01-02T12:42:14.976582+00:00 | 2025-01-02T12:42:14.976582+00:00 | 23 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity: O(N^ 2)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ ... | 1 | 0 | ['C++'] | 0 |
max-increase-to-keep-city-skyline | Simple Approach Greedily | simple-approach-greedily-by-dhruv_6395-duek | IntuitionApproach :Find maximums of a particular row and corresponding column and then take minimum of it and increment the grid[i][j] value upto minimum of max | Dhruv_0036 | NORMAL | 2024-12-30T09:42:02.923825+00:00 | 2024-12-30T09:42:02.923825+00:00 | 13 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach :
<!-- Describe your approach to solving the problem. -->
Find maximums of a particular row and corresponding column and then take minimum of it and increment the grid[i][j] value upto minimum of maximums + 1.
# Complexity
- T... | 1 | 0 | ['Array', 'Greedy', 'Matrix', 'C++'] | 0 |
max-increase-to-keep-city-skyline | C++ Easiest way Solution | c-easiest-way-solution-by-jeetgajera-e9q9 | 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 | Jeetgajera | NORMAL | 2024-09-11T05:07:43.226510+00:00 | 2024-09-11T05:07:43.226535+00:00 | 6 | 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 : O(N*N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity : O(N)\n<!-- Add your space complexity here, e.... | 1 | 0 | ['Greedy', 'Matrix', 'C++'] | 0 |
max-increase-to-keep-city-skyline | Straightforward Easy C++ Solution | straightforward-easy-c-solution-by-bhart-3mx6 | Intuition\nIn the problem, we\'re asked to modify the grid such that the new grid has the same skyline when viewed from both the top/bottom and left/right.\n\nM | bharti_pd | NORMAL | 2024-08-13T16:35:46.806678+00:00 | 2024-08-13T16:37:54.868978+00:00 | 33 | false | # Intuition\nIn the problem, we\'re asked to modify the grid such that the new grid has the same skyline when viewed from both the top/bottom and left/right.\n\nMy observation during the dry run was that the grid can be altered such that the new height of each building is determined by the smaller value between the max... | 1 | 0 | ['Array', 'Greedy', 'Matrix', 'C++'] | 0 |
max-increase-to-keep-city-skyline | EASY C++ SOLUTION ✅✅🔥🔥 | easy-c-solution-by-baladharun-43uj | Intuition\n1. we have to calculate how much each building can be increased without changing the skyline, ensuring that the increase respects the maximum heights | Baladharun | NORMAL | 2024-07-05T08:56:08.769585+00:00 | 2024-07-05T08:56:08.769620+00:00 | 10 | false | # Intuition\n1. we have to calculate how much each building can be increased without changing the skyline, ensuring that the increase respects the maximum heights from both the row and column perspectives.\n1. Finally, it sums up all the possible increases and returns the result.\n2. It can be done by **min(max(row[i],... | 1 | 0 | ['C++'] | 0 |
max-increase-to-keep-city-skyline | Easy C++ Solution | Beats 77% | easy-c-solution-beats-77-by-deepak2k03-vl0z | Intuition\nIt can be solved greedily\n\n# Approach\nFor every element find minimum of maximum elements in that row and column, i.e and subtract that element fro | deepak2k03 | NORMAL | 2024-05-26T02:06:41.867799+00:00 | 2024-05-26T02:06:41.867819+00:00 | 6 | false | # Intuition\nIt can be solved greedily\n\n# Approach\nFor every element find minimum of maximum elements in that row and column, i.e and subtract that element from that and add the result in a storing variable.\n\n# Complexity\n- Time complexity:\nO(n^2)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\npu... | 1 | 0 | ['C++'] | 0 |
max-increase-to-keep-city-skyline | Simple Approach: Maximize Building Heights for Unchanged Skylines | simple-approach-maximize-building-height-7mdr | Explanation of the Problem\nThink of a city with buildings of different heights arranged like a grid. The goal is to make the buildings taller but without chang | shrutika-07 | NORMAL | 2024-02-22T11:34:21.823720+00:00 | 2024-02-22T11:34:21.823744+00:00 | 57 | false | # Explanation of the Problem\nThink of a city with buildings of different heights arranged like a grid. The goal is to make the buildings taller but without changing how the city looks when you see it from any side. We want to figure out the maximum amount by which we can increase the heights of the buildings without a... | 1 | 0 | ['Array', 'Math', 'Greedy', 'Matrix', 'C++', 'Java'] | 0 |
max-increase-to-keep-city-skyline | Swift solution | swift-solution-by-azm819-rwkx | Complexity\n- Time complexity: O(n * m)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n + m)\n Add your space complexity here, e.g. O(n) | azm819 | NORMAL | 2024-02-06T14:22:51.189110+00:00 | 2024-02-06T14:22:51.189131+00:00 | 3 | false | # Complexity\n- Time complexity: $$O(n * m)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n + m)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n func maxIncreaseKeepingSkyline(_ grid: [[Int]]) -> Int {\n var rowMax = Array(repe... | 1 | 0 | ['Array', 'Greedy', 'Swift', 'Matrix'] | 0 |
max-increase-to-keep-city-skyline | 🔥Beats 100% 🔥 Simple & best java solution. | beats-100-simple-best-java-solution-by-r-tv5b | Complexity\n- Time complexity : 0 MS\n Add your time complexity here, e.g. O(n) \n\n- Space complexity : 43 MB\n Add your space complexity here, e.g. O(n) \n\n# | Ronak_Thesiya | NORMAL | 2023-09-25T13:49:03.470436+00:00 | 2023-09-25T13:49:03.470457+00:00 | 554 | false | # Complexity\n- Time complexity : 0 MS\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity : 43 MB\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n int n=grid.length;\n int arr1[]=n... | 1 | 0 | ['Java'] | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.