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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
counting-words-with-a-given-prefix | Just 3 lines code🤯❤️🔥Most easy solution✅👨🏻💻Beats 💯% solutions on LeetCode🐦🔥 | just-3-lines-codemost-easy-solutionbeats-0t6b | IntuitionFirst of all on reading the question I realised that we just need to count the number of words in the given array which have given word as prefix and t | codonaut_anant_05 | NORMAL | 2025-01-09T15:17:05.987936+00:00 | 2025-01-09T15:17:05.987936+00:00 | 8 | false | # Intuition
First of all on reading the question I realised that we just need to count the number of words in the given array which have given word as prefix and then simply return that count.

# Approa... | 2 | 0 | ['Array', 'String', 'C++'] | 0 |
counting-words-with-a-given-prefix | Easy C++ Beats 100% | easy-c-beats-100-by-abhishek-verma01-61ku | IntuitionThe problem requires counting how many strings in the listwordsstart with a specific prefix pref.
The solution involves checking each string in the lis | Abhishek-Verma01 | NORMAL | 2025-01-09T14:27:25.941046+00:00 | 2025-01-09T14:27:25.941046+00:00 | 9 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem requires counting how many strings in the list` words `start with a specific prefix `pref.`
The solution involves checking each string in the list to see if its first few characters match the prefix. If they do, the count is inc... | 2 | 0 | ['Array', 'String', 'String Matching', 'Counting', 'C++'] | 0 |
counting-words-with-a-given-prefix | Super easy solution in python. (beats 100%) - one liner solution. | super-easy-solution-in-python-beats-100-mohhp | IntuitionHere we need to find that if the string present in array starts with the given prefix.ApproachThe approach for this is super easy. We just need to loop | shwet_46 | NORMAL | 2025-01-09T14:19:38.686059+00:00 | 2025-01-09T14:28:11.318380+00:00 | 7 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Here we need to find that if the string present in array starts with the given prefix.
# Approach
<!-- Describe your approach to solving the problem. -->
The approach for this is super easy. We just need to loop through words list and chec... | 2 | 0 | ['Array', 'String', 'String Matching', 'Python3'] | 0 |
counting-words-with-a-given-prefix | beats:100%, 1 line javascript solution | 1-line-javascript-solution-by-baesumin-1fyi | IntuitionApproachComplexity
Time complexity: O(n*k)
Space complexity: O(n)
Code | baesumin | NORMAL | 2025-01-09T13:25:54.821457+00:00 | 2025-01-09T23:54:11.135260+00:00 | 16 | 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*k)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -... | 2 | 0 | ['Array', 'String', 'String Matching', 'JavaScript'] | 0 |
counting-words-with-a-given-prefix | Beginner friendly, beats 100% | beginner-friendly-beats-100-by-akshitha_-4q7p | IntuitionTo check every word in the words[] array starts with the given prefix pref.Approach
Initialize a variable int count=0 to keep the track of the words in | Akshitha_Naverse | NORMAL | 2025-01-09T13:20:12.865889+00:00 | 2025-01-09T13:20:12.865889+00:00 | 6 | false | # Intuition
To check every word in the `words[]` array starts with the given prefix `pref`.
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
- Initialize a variable `int count=0` to keep the track of the words in the `words[]` array which start with the given prefix `pref`.
- Simply chec... | 2 | 0 | ['Java'] | 0 |
counting-words-with-a-given-prefix | Simple Cpp Solution | simple-cpp-solution-by-arpita_sat-m5mq | ApproachIterate through elements of words and just compare te starting characters of each word with the pref string.Complexity
Time complexity: O(n*m) where n = | arpita_sat | NORMAL | 2025-01-09T12:56:29.333850+00:00 | 2025-01-09T12:56:29.333850+00:00 | 11 | false |
# Approach
<!-- Describe your approach to solving the problem. -->
Iterate through elements of words and just compare te starting characters of each word with the pref string.
# Complexity
- Time complexity: O(n*m) where n = number of words and m = length of pref string
<!-- Add your time complexity here, e.g. $$O(n)... | 2 | 0 | ['C++'] | 0 |
counting-words-with-a-given-prefix | My minimal and easy solution in c++ | my-minimal-and-easy-solution-in-c-by-mo7-sqz7 | My Code | Mo7amed_3bdelghany | NORMAL | 2025-01-09T12:43:30.387880+00:00 | 2025-01-09T12:43:30.387880+00:00 | 14 | false |
# My Code
```cpp []
class Solution {
public:
int prefixCount(vector<string>& words, string pref) {
int count = 0, n = pref.size();
for(auto it: words){
if(it.substr(0, n) == pref)
count++;
}
return count;
}
};
``` | 2 | 0 | ['String Matching', 'C++'] | 0 |
counting-words-with-a-given-prefix | Easy solution || Beats 100% | easy-solution-beats-100-by-shantanusaxen-safv | IntuitionMatching every character of pref with the the prefixes of strings present in words array.Approach
Iterate through every element in the array. And initi | ShantanuSaxena | NORMAL | 2025-01-09T11:49:49.036811+00:00 | 2025-01-09T11:49:49.036811+00:00 | 8 | false | 
# Intuition
Matching every character of pref with the the prefixes of strings present in words array.
# Approach
1. Iterate through every element in the array. And initia... | 2 | 0 | ['C++'] | 0 |
counting-words-with-a-given-prefix | JAVA | Faster Than 100% | Runtime : 1ms | java-faster-than-100-runtime-1ms-by-07_d-esah | Complexity
Time complexity: O(N)
Space complexity: O(N)
Code | 07_deepak | NORMAL | 2025-01-09T11:09:07.026557+00:00 | 2025-01-09T11:09:07.026557+00:00 | 10 | 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
```java []
class Solution {
public int prefixCount(String[] words, String pref) {
int n=pref.length(),c=0;
for(... | 2 | 0 | ['Java'] | 0 |
counting-words-with-a-given-prefix | Very Easy Detailed Solution 🔥 || 🔥 Beats 100% || 🎯 Two Approaches | very-easy-detailed-solution-beats-100-tw-92ow | Approach 1:
Helper Function (isPrefix):
Checks if a string (str1) starts with another string (pref) by comparing the substring of str1 of length equal to pref | chaturvedialok44 | NORMAL | 2025-01-09T10:31:50.065115+00:00 | 2025-01-09T10:31:50.065115+00:00 | 28 | false | # Approach 1:
<!-- Describe your approach to solving the problem. -->
1. **Helper Function (isPrefix):**
- Checks if a string (str1) starts with another string (pref) by comparing the substring of str1 of length equal to pref.
- If the length of str1 is less than the length of pref, it immediately returns false... | 2 | 0 | ['Array', 'String', 'String Matching', 'Counting', 'Java'] | 2 |
properties-graph | [C++ & Java] DSU || Simple and easy to understand solution | dsu-simple-and-easy-to-understand-soluti-x4vt | Intuition
find if the nodes are connected or not. we just need to check each item of each property to be checked in the other item property, if its present or n | kreakEmp | NORMAL | 2025-03-23T04:02:11.601008+00:00 | 2025-03-23T05:26:26.063743+00:00 | 2,376 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
- find if the nodes are connected or not. we just need to check each item of each property to be checked in the other item property, if its present or not. To do this further we can create a map of set and push each item to it. the other wa... | 14 | 0 | ['C++', 'Java'] | 5 |
properties-graph | ⚡EASY✅ AND SHORT CODE🍨|| BEATS 💯🚀||【C++/Java/Py3/JS】⌚CLEAN EXPLANATION ⌚ | easy-and-short-code-beats-cjavapy3js-cle-iik9 | IntuitionWe need to construct an undirected graph where each node represents a row in the properties matrix. An edge exists between two nodes if the intersectio | Fawz-Haaroon | NORMAL | 2025-03-23T06:06:55.957822+00:00 | 2025-03-23T17:03:58.954297+00:00 | 1,399 | false | # **Intuition**
We need to construct an undirected graph where each node represents a row in the `properties` matrix. An edge exists between two nodes if the intersection of their respective lists contains at least `k` common elements. The problem then reduces to counting the number of connected components in this gr... | 12 | 1 | ['Union Find', 'Graph', 'Matrix', 'Prefix Sum', 'Python', 'C++', 'Java', 'Python3', 'JavaScript'] | 1 |
properties-graph | UnionFind with rank + bitset|C++ beats 100% | unionfind-with-rank-bitsetc-beats-9314-b-fitl | IntuitionSolveed by Union find with optimation by rank.
To implement the interesection by using bitsetApproach[LC1971 uses this UnionFind class with rank. Pleas | anwendeng | NORMAL | 2025-03-23T10:13:39.681488+00:00 | 2025-03-24T23:48:07.771054+00:00 | 393 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Solveed by Union find with optimation by rank.
To implement the interesection by using bitset
# Approach
<!-- Describe your approach to solving the problem. -->
[LC1971 uses this UnionFind class with rank. Please turn English subtitles if n... | 10 | 0 | ['Bit Manipulation', 'Union Find', 'C++'] | 3 |
properties-graph | C++ | Easy To Understand | DFS Must Learn For Interviews | c-easy-to-understand-dfs-must-learn-for-m1btr | Intuition
The problem involves determining the number of connected components in a graph where nodes represent elements with certain properties. Two nodes are c | kirthik | NORMAL | 2025-03-23T07:55:46.309614+00:00 | 2025-03-23T08:01:55.192337+00:00 | 582 | false | **Intuition**
The problem involves determining the number of connected components in a graph where nodes represent elements with certain properties. Two nodes are connected if they share at least k properties. Our goal is to construct this graph and then count the number of connected components.
**Approach**
- Build t... | 8 | 0 | ['Depth-First Search', 'C++'] | 0 |
properties-graph | Easy & Detailed Explanation✅ | DSU | Union - Find | C++ | Java | Python | Js | easy-detailed-explanation-dsu-union-find-6nxl | 🧠 IntuitionThe problem requires finding the number of connected components in a graph where each node represents a list of elements.
Two nodes are connected if | himanshu_dhage | NORMAL | 2025-03-23T04:05:11.840943+00:00 | 2025-03-23T04:05:11.840943+00:00 | 947 | false | # 🧠 Intuition
The problem requires finding the number of connected components in a graph where each node represents a list of elements.
Two nodes are connected if they share **at least k common elements**.
A **union-find (disjoint set)** data structure is well-suited for this task as it efficiently merges compon... | 8 | 1 | ['Hash Table', 'Union Find', 'C++', 'Java', 'Python3', 'JavaScript'] | 1 |
properties-graph | Fastest C++ | Beats 100% | Easy and explained | fastest-c-beats-100-easy-and-explained-b-evwi | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | AK200199 | NORMAL | 2025-03-23T07:37:22.367655+00:00 | 2025-03-23T07:37:22.367655+00:00 | 504 | 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
`... | 6 | 0 | ['C++'] | 2 |
properties-graph | ✅ Do as they say ✅ | do-as-they-say-by-ajay_prabhu-4puc | IntuitionTo solve this problem, I need to build a graph where nodes are connected based on the number of common elements they share. Then I need to count the co | Ajay_Prabhu | NORMAL | 2025-03-23T06:27:03.450161+00:00 | 2025-03-23T06:27:03.450161+00:00 | 180 | false | # Intuition
To solve this problem, I need to build a graph where nodes are connected based on the number of common elements they share. Then I need to count the connected components in this graph.
# Approach
1. Build an adjacency list representation of the graph:
- For each pair of arrays, calculate the number of d... | 6 | 0 | ['Hash Table', 'Breadth-First Search', 'Graph', 'Java'] | 1 |
properties-graph | Union-Find and Set Intersection | union-find-and-set-intersection-by-votru-enbw | First, we convert properties to sets so we can use set_intersection.Then, we go though each pair and check if they are already in the same set (find operation). | votrubac | NORMAL | 2025-03-23T04:12:00.019127+00:00 | 2025-03-23T04:12:00.019127+00:00 | 556 | false | First, we convert properties to sets so we can use `set_intersection`.
Then, we go though each pair and check if they are already in the same set (find operation).
If not, we check for the set intersection, and join these two elements.
# Code
```cpp []
int find(int i, vector<int> &ds) {
return ds[i] < 0 ? i : ... | 6 | 0 | ['C++'] | 2 |
properties-graph | Use union find | use-union-find-by-thomashsiao-5n47 | IntuitionWhen we look at the description carefully, we can find some hints.
First, it is an undirected graph.
Second, it requires the number of connected compon | ThomasHsiao | NORMAL | 2025-03-23T09:15:53.995070+00:00 | 2025-03-23T09:17:00.179360+00:00 | 166 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
When we look at the description carefully, we can find some hints.
First, it is an undirected graph.
Second, it requires the number of connected components in the resulting graph.
From the second hint, we can image we only need root for ev... | 4 | 0 | ['Union Find', 'C++', 'Java', 'Python3'] | 0 |
properties-graph | 😀100% User Beat | 💡 DFS | Java | 100-user-beat-dfs-java-by-s_a_m2003-qhmd | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | s_a_m2003 | NORMAL | 2025-03-24T10:58:02.334091+00:00 | 2025-03-24T10:58:02.334091+00:00 | 52 | 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 | ['Depth-First Search', 'Graph', 'Java'] | 1 |
properties-graph | Efficiently Counting Connected Components in a Graph Using DFS (Adjacency List) | efficiently-counting-connected-component-eiik | IntuitionThe problem requires us to construct a graph where each node represents a list of properties. An edge exists between two nodes if the number of common | pravardhan_100 | NORMAL | 2025-03-23T04:38:04.369939+00:00 | 2025-03-23T04:38:04.369939+00:00 | 199 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem requires us to construct a graph where each node represents a list of properties. An edge exists between two nodes if the number of common elements in their respective lists is at least k. Our goal is to determine the number of ... | 3 | 0 | ['Java'] | 1 |
properties-graph | SIMPLE DFS APPROACH USING PYTHON | simple-dfs-approach-using-python-by-vish-33x4 | Complexity
Time complexity:
O(n2)
Space complexity:
O(n)
Code | VISHAAL-KUMAR | NORMAL | 2025-03-23T04:18:43.726301+00:00 | 2025-03-23T04:18:43.726301+00:00 | 196 | false | # Complexity
- Time complexity:
O(n2)
- Space complexity:
O(n)
# Code
```python3 []
from collections import defaultdict
class Solution:
def numberOfComponents(self, properties: List[List[int]], k: int) -> int:
n = len(properties)
res = 1
visit = set()
visit.add(0)
graph =... | 3 | 0 | ['Python3'] | 1 |
properties-graph | simple c++ solution | simple-c-solution-by-22h51a66e5-7zg6 | IntuitionApproachComplexity
Time complexity:
Worst-case O(n² * m)
Space complexity:
O(n * m)Code | 22h51a66e5 | NORMAL | 2025-03-23T04:06:17.352227+00:00 | 2025-03-23T04:06:17.352227+00:00 | 139 | 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)$$ -->
Worst-case O(n² * m)
- Space complexity:
<!-- Add your space complexity here, e.... | 3 | 0 | ['C++'] | 0 |
properties-graph | DSU based solution | dsu-based-solution-by-anubhavpathak03-u02a | I approched this solution by DSUI first solve these question to do this questionQuestion-1 (common element b/w two arrays)Question-2 (count the number of comple | anubhavpathak03 | NORMAL | 2025-03-24T10:42:13.148998+00:00 | 2025-03-24T10:42:13.148998+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... | 2 | 0 | ['Union Find', 'C++'] | 0 |
properties-graph | Python3 || dfs || T/S: 84% / 99% | python3-dfs-ts-84-99-by-spaulding-9xwi | https://leetcode.com/problems/properties-graph/submissions/1583589292/I could be wrong, but I think that time complexity is *O(N ^2 * M) and space complexity is | Spaulding_ | NORMAL | 2025-03-23T18:44:10.916932+00:00 | 2025-03-23T18:44:10.916932+00:00 | 14 | false | ```python3 []
class Solution:
def numberOfComponents(self, properties: List[List[int]], k: int) -> int:
def areConnected(list1, list2):
return len(set(list1) & set(list2)) >= k
def dfs(node: int) -> None:
stack = [node]
while stack:
node = stack... | 2 | 0 | ['Python3'] | 0 |
properties-graph | 🏗️ Counting Connected Components in a Graph 🏗️ | counting-connected-components-in-a-graph-2muy | 💡 Intuition:We need to determine how many connected components exist in a graph constructed from the given properties array.Each index in properties represents | opWzPXRgDd | NORMAL | 2025-03-23T04:29:57.000931+00:00 | 2025-03-23T04:29:57.000931+00:00 | 97 | false | # 💡 Intuition:
<!-- Describe your first thoughts on how to solve this problem. -->
We need to determine how many connected components exist in a graph constructed from the given `properties` array.
Each index in `properties` represents a node, and an edge is formed between two nodes if they share at least `k` common ... | 2 | 0 | ['Array', 'Depth-First Search', 'Graph', 'Python3'] | 0 |
properties-graph | Python | Union Find | python-union-find-by-prince0018-ej6h | Code | prince0018 | NORMAL | 2025-03-23T04:06:50.855968+00:00 | 2025-03-23T04:06:50.855968+00:00 | 49 | false | # Code
```python3 []
class Solution:
def numberOfComponents(self, properties: List[List[int]], k: int) -> int:
edges=[]
for x in range(len(properties)-1):
for y in range(x+1,len(properties)):
hash1=set(Counter(properties[x]).keys())
hash2=set(Counter(prope... | 2 | 0 | ['Union Find', 'Python3'] | 1 |
properties-graph | ✅ ⟣ Java Solution ⟢ | java-solution-by-harsh__005-hil7 | Code | Harsh__005 | NORMAL | 2025-03-23T04:02:08.899679+00:00 | 2025-03-23T04:02:08.899679+00:00 | 78 | false | # Code
```java []
class Solution {
private void dfs(boolean[] used, Map<Integer, List<Integer>> map, int v) {
used[v] = true;
for(int child : map.getOrDefault(v, new ArrayList<>())) {
if(!used[child]) {
dfs(used, map, child);
}
}
}
public ... | 2 | 0 | ['Java'] | 1 |
properties-graph | Easy cpp and Java✅ | easy-cpp-and-java-by-pune18-ti65 | IntuitionThe problem involves finding the number of connected components in a graph where nodes represent arrays, and edges exist between nodes if they share at | pune18 | NORMAL | 2025-03-23T04:02:04.598888+00:00 | 2025-03-24T01:46:05.568886+00:00 | 129 | false | # Intuition
The problem involves finding the number of connected components in a graph where nodes represent arrays, and edges exist between nodes if they share at least k distinct common integers. The key insight is to model this as a graph problem and use Depth-First Search (DFS) to count the connected components.
#... | 2 | 1 | ['Ordered Map', 'Ordered Set', 'C++', 'Java'] | 1 |
properties-graph | C, Union-Find 100% | c-union-find-100-by-nikamir-955r | IntuitionUse union-find, use the bit masks to store the propertiesComplexity
Time complexity:
O(n2)
Space complexity:
O(n)
Code | nikamir | NORMAL | 2025-03-31T20:12:04.219258+00:00 | 2025-03-31T20:38:30.159501+00:00 | 9 | false | # Intuition
Use union-find, use the bit masks to store the properties
# Complexity
- Time complexity:
$$O(n^2)$$
- Space complexity:
$$O(n)$$
# Code
```c []
/* hold bits for ~100 properties 2x64 bit numbers*/
typedef struct {
/* tree of sets, set size, link to parent */
unsigned char size, parent;
unsigned... | 1 | 0 | ['C'] | 0 |
properties-graph | Beginner Friendly Adjacency List + DFS using unordered sets | C++ | Beats 100% | beginner-friendly-adjacency-list-dfs-usi-ng3v | IntuitionEach row is converted to a set to eliminate duplicates. For all pairs of rows, edges are added if their intersection size meets k. Finally, DFS travers | pratiiik_p | NORMAL | 2025-03-28T10:03:33.085818+00:00 | 2025-03-28T10:03:33.085818+00:00 | 17 | false | # Intuition
Each row is converted to a set to eliminate duplicates. For all pairs of rows, edges are added if their intersection size meets `k`. Finally, DFS traverses the graph to count connected components.
# Approach
1. **Preprocessing Rows into Sets:**
- Convert each row into an `unordered_set` to eliminate du... | 1 | 0 | ['Hash Table', 'Depth-First Search', 'Ordered Set', 'C++'] | 0 |
properties-graph | Beginners Friendly ! Easy to Understand | beginners-friendly-easy-to-understand-by-2fwt | IntuitionApproachComplexity
Time complexity: O(n*m)
Space complexity: O(n*m)
Code | jayprakash00012 | NORMAL | 2025-03-28T06:44:53.901166+00:00 | 2025-03-28T06:44:53.901166+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: O(n*m)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(n*m)
<!-- Add your space complexity here, e.g. $$O(n)$$... | 1 | 0 | ['Array', 'Hash Table', 'Depth-First Search', 'Graph', 'C++'] | 0 |
properties-graph | Disjoint Set & Set intersection - Python solution | disjoint-set-set-intersection-python-sol-m0ed | Intuition & ApproachThis problem can be divited (and the conquered) into two smaller problems.IntersectionWe need an efficient way to find number of distinct in | agayev169 | NORMAL | 2025-03-26T13:46:04.693892+00:00 | 2025-03-26T13:47:02.415755+00:00 | 14 | false | # Intuition & Approach
This problem can be divited (and the conquered) into two smaller problems.
## Intersection
We need an efficient way to find number of distinct integers common to two arrays. The most efficient way to do this is to pre-convert all the arrays to sets and then do an intersection operation between ... | 1 | 0 | ['Hash Table', 'Union Find', 'Graph', 'Python3'] | 1 |
properties-graph | Simple and easy to understand | BFS | Python3 | Beats 80% | simple-and-easy-to-understand-bfs-python-pogq | Please UpvoteCode | Alpha2404 | NORMAL | 2025-03-26T02:16:48.559953+00:00 | 2025-03-26T02:16:48.559953+00:00 | 11 | false | # Please Upvote
# Code
```python3 []
class Solution:
def numberOfComponents(self, properties: List[List[int]], k: int) -> int:
n = len(properties)
m = len(properties[0])
def intersect(a, b):
return len(set(a).intersection(set(b)))
adj = defaultdict(list)
for i in... | 1 | 0 | ['Array', 'Hash Table', 'Breadth-First Search', 'Graph', 'Python3'] | 0 |
properties-graph | Simple || DFS || Beginner Friendly || Counting ✅🎯 | simple-dfs-beginner-friendly-counting-by-6lzt | Approach:dfs(u, vis, adj):
Standard depth-first search (DFS) to traverse connected components in an adjacency list representation of a graph.
Marks visited node | mayankn31 | NORMAL | 2025-03-24T19:14:48.065845+00:00 | 2025-03-24T19:14:48.065845+00:00 | 20 | false | # Approach:
## dfs(u, vis, adj):
- Standard depth-first search (DFS) to traverse connected components in an adjacency list representation of a graph.
- Marks visited nodes to avoid reprocessing.
## intersect(a, b):
- Uses two binary arrays (one and two) of size 101 to track the presence of numbers in arrays a and b.
... | 1 | 0 | ['Array', 'Hash Table', 'Depth-First Search', 'Graph', 'Counting', 'C++'] | 0 |
properties-graph | 😀100% User Beat | 💡 DFS | Java | 100-user-beat-dfs-java-by-s_a_m2003-cg3f | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | s_a_m2003 | NORMAL | 2025-03-24T10:56:50.666949+00:00 | 2025-03-24T10:56:50.666949+00:00 | 13 | 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 | ['Depth-First Search', 'Graph', 'Java'] | 0 |
properties-graph | simple intuitive approach .beats 78 perc . o(n2) . | simple-intuitive-approach-beats-78-perc-rbcun | Approachfirst we will sort all the arrays in properties and remove their duplicates.
then we will take 2 arrays and check if their intersection ( ie common uniq | alokth1302 | NORMAL | 2025-03-24T01:49:21.091032+00:00 | 2025-03-24T01:49:21.091032+00:00 | 9 | false |
# Approach
first we will sort all the arrays in properties and remove their duplicates.
then we will take 2 arrays and check if their intersection ( ie common unique elements) is greater than k.
to do this we have used a 2 pointers approach.
if intersection comes out to be greater than k .we form an undirected edge b... | 1 | 0 | ['C++'] | 0 |
properties-graph | DSU/UnionFind. 450ms | dsuunionfind-by-vokasik-y86x | Code | vokasik | NORMAL | 2025-03-23T23:49:41.342978+00:00 | 2025-03-23T23:50:24.465864+00:00 | 11 | false | # Code
```python3
class Solution:
def numberOfComponents(self, grid: List[List[int]], k: int) -> int:
def union(a,b):
nonlocal components
if (roota := find(a)) != (rootb := find(b)):
if sizes[roota] > sizes[rootb]:
parents[rootb] = roota
... | 1 | 0 | ['Union Find', 'Python3'] | 0 |
properties-graph | Optimal DFS Solution in C++, JAVA & PYTHON | optimal-dfs-solution-in-c-java-python-by-ofdg | Understanding Connected Components in Graphs: A Multi-Language ApproachIntroductionConnected components are a fundamental concept in graph theory, often used in | dipesh1203 | NORMAL | 2025-03-23T20:15:25.869284+00:00 | 2025-03-23T20:15:25.869284+00:00 | 26 | false | # Understanding Connected Components in Graphs: A Multi-Language Approach
## Introduction
Connected components are a fundamental concept in graph theory, often used in clustering problems, social network analysis, and recommendation systems. In this blog, we will explore an efficient approach to solving a problem invo... | 1 | 0 | ['Depth-First Search', 'Graph', 'Ordered Set', 'Python', 'C++', 'Java', 'Python3'] | 0 |
properties-graph | Easy solution using Map and Set | easy-solution-using-map-and-set-by-abh15-v16f | Approach
Use a map array to store the connected node.
Check every possible pair. For each pair i,j:
If 2 nodes i&j are connected, store the smallest of ther | Abh15hek | NORMAL | 2025-03-23T20:10:41.271137+00:00 | 2025-03-23T20:10:41.271137+00:00 | 8 | false | # Approach
<!-- Describe your approach to solving the problem. -->
- Use a map array to store the connected node.
- Check every possible pair. For each pair i,j:
- If 2 nodes i&j are connected, store the smallest of there map values in both map[i] and map[j].
- Add the minimum value of the connected nodes in set
... | 1 | 0 | ['Java'] | 0 |
properties-graph | C++ || Simple and Easy Explanation || Union-Find | c-simple-and-easy-explanation-union-find-ayln | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | jhanvi_sankhla | NORMAL | 2025-03-23T17:27:40.079544+00:00 | 2025-03-23T17:27:40.079544+00:00 | 8 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We need to find connected components,
The most intitutive approach for that is Union Set.
# Approach
<!-- Describe your approach to solving the problem. -->
1.Write a function for intersect using two pointer.
For that ... | 1 | 0 | ['Two Pointers', 'Union Find', 'C++'] | 0 |
properties-graph | C++ Solution simple approach using graph construction and dfs | c-solution-simple-approach-using-graph-c-ad1r | ApproachFor the given constraints, following approach works fine.
Construct a graph using the given approach and then find number of connected componentsComplex | kavya_naik | NORMAL | 2025-03-23T14:17:58.853188+00:00 | 2025-03-23T14:19:45.868625+00:00 | 29 | false | # Approach
For the given constraints, following approach works fine.
Construct a graph using the given approach and then find number of connected components
# Complexity
- Time complexity: $$O(n^2 * m * log(m))$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: $$O(n ^ 2)$$
<!-- Add your spac... | 1 | 0 | ['Array', 'Greedy', 'Depth-First Search', 'Graph', 'Ordered Set', 'Strongly Connected Component', 'C++'] | 0 |
properties-graph | 🧩🤙🏻 Count Connected Components Based on Shared Properties (Using DSU / Union Find)💦🚀 | count-connected-components-based-on-shar-e70i | IntuitionTo determine the number of connected components where each component is formed by groups of items sharing at least k common properties, we can treat th | udit_s05 | NORMAL | 2025-03-23T14:00:44.924474+00:00 | 2025-03-23T14:01:23.286586+00:00 | 26 | false | # Intuition
To determine the number of connected components where each component is formed by groups of items sharing at least k common properties, we can treat this as a graph problem. Each item is a node, and there is an edge between two nodes if they share k or more properties. This leads to the formation of disjoin... | 1 | 0 | ['Array', 'Union Find', 'Graph', 'Ordered Set', 'C++'] | 0 |
properties-graph | Oh really So much to do. | oh-really-so-much-to-do-by-madhavendrasi-9j8p | IntuitionFirst divide the part and then understand the concept.ApproachSo first make the function which return count of commman number and thenalso make dfs fu | Madhavendrasinh44 | NORMAL | 2025-03-23T12:39:03.055875+00:00 | 2025-03-23T12:39:03.055875+00:00 | 25 | false | # Intuition
First divide the part and then understand the concept.
# Approach
So first make the function which return count of commman number and thenalso make dfs function then sort the prop arrays and make them unique and thenmake the call for the common count then make the adjancent list. and then return the connec... | 1 | 0 | ['Depth-First Search', 'Counting Sort', 'C++'] | 0 |
properties-graph | Beginner-Friendly || JAVA | beginner-friendly-java-by-gauraabhas-ifdo | IntuitionThe problem involves finding connected components based on shared properties between items. We can represent this as a graph problem, where nodes repre | gauraabhas | NORMAL | 2025-03-23T10:29:04.641285+00:00 | 2025-03-23T10:29:04.641285+00:00 | 13 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem involves finding connected components based on shared properties between items. We can represent this as a graph problem, where nodes represent items, and edges exist between nodes if they share at least k common properties.
# A... | 1 | 0 | ['Depth-First Search', 'Graph', 'Java'] | 0 |
properties-graph | Easy | C++ | Connected Components | easy-c-connected-components-by-wait_watc-w17a | IntuitionApproach
Graph Construction:
Treat each row in properties as a node.
Use intersect() function to determine if two nodes are connected.
If two rows sh | wait_watch | NORMAL | 2025-03-23T09:55:05.439121+00:00 | 2025-03-26T13:30:59.773790+00:00 | 33 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
1. **Graph Construction:**
- Treat each row in `properties` as a node.
- Use `intersect()` function to determine if two nodes are connected.
- If two rows share at... | 1 | 0 | ['Graph', 'C++'] | 0 |
properties-graph | [Go, Python3] 0ms 9.26MB Fastest Go solution using Union Find and BitMask with explanations | go-python3-0ms-926-fastest-go-solution-u-u9ug | IntuitionWe need to count how many connected components exist in the graph, and the Union-Find (Disjoint Set Union) algorithm is a perfect fit for this type of | I4TL | NORMAL | 2025-03-23T09:50:17.353364+00:00 | 2025-03-23T09:51:41.947896+00:00 | 20 | false | 
# Intuition
We need to count how many connected components exist in the graph, and the **Union-Find** (Disjoint Set Union) algorithm is a perfect fit for this type of problem. Which is special about this ... | 1 | 0 | ['Bit Manipulation', 'Union Find', 'Bitmask', 'Go', 'Python3'] | 0 |
properties-graph | Using BFS | using-bfs-by-udaykiran2427-kocx | IntuitionThe question is the algorithm! We have to follow the steps given:
Write intersect(a, b), which counts common elements of both.
For every array where i | udaykiran2427 | NORMAL | 2025-03-23T09:46:36.494271+00:00 | 2025-03-23T09:46:36.494271+00:00 | 20 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The question is the algorithm! We have to follow the steps given:
1. Write `intersect(a, b)`, which counts common elements of both.
2. For every array where `i != j`, check if `count >= k`. If true, create an edge between `i` and `j`. You c... | 1 | 0 | ['Breadth-First Search', 'C++'] | 0 |
properties-graph | Create Adjacency List then DFS | O(N * M) in 3ms | Rust | create-adjacency-list-then-dfs-on-m-in-3-ndba | Complexity
Time complexity: O(N∗M)
Space complexity: O(N∗M)
Code | Prog_Jacob | NORMAL | 2025-03-23T05:08:42.371129+00:00 | 2025-03-23T05:08:42.371129+00:00 | 13 | false | # Complexity
- Time complexity: $$O(N * M)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: $$O(N * M)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```rust []
impl Solution {
pub fn number_of_components(properties: Vec<Vec<i32>>, k: i32) -> i32 {
let n = prope... | 1 | 0 | ['Rust'] | 0 |
properties-graph | Simple C++ with DFS | simple-c-with-dfs-by-prajakta_1510-ubqh | IntuitionApproachComplexity
Time complexity: O(N^2 * M)
Space complexity: O(N^2) + O(N) + O(M)
Code | prajakta_1510 | NORMAL | 2025-03-23T04:47:36.213372+00:00 | 2025-03-23T04:47:36.213372+00:00 | 68 | 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 * M)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(N^2) + O(N) + O(M)
<!-- Add your space complexity h... | 1 | 0 | ['Graph', 'Sorting', 'C++'] | 0 |
properties-graph | Union Find + Bitmask, 4 ms Java Beats 100%. | union-find-bitmask-4-ms-java-beats-100-b-w7jl | Instead of entire hashsets, the limited scope of nums allows us to use two different longs to fit all 100 different nums into the 128 bits of the longs.This all | NickUlman | NORMAL | 2025-03-23T04:47:00.070044+00:00 | 2025-03-23T04:47:00.070044+00:00 | 26 | false | Instead of entire hashsets, the limited scope of nums allows us to use two different longs to fit all 100 different nums into the 128 bits of the longs.
This allows us to calculate the intersection of any two rows unique vals by just taking the bitwise and of the masks. From here can just get the bitcount of the bitw... | 1 | 0 | ['Bit Manipulation', 'Union Find', 'Java'] | 0 |
properties-graph | Simple Brute force | DSU | simple-brute-force-dsu-by-mayberon-dtfp | Code | MaybeRon | NORMAL | 2025-03-23T04:37:56.435150+00:00 | 2025-03-23T04:37:56.435150+00:00 | 53 | false | # Code
```cpp []
class Solution {
public:
struct DSU{
vector<int> par, chi;
int components = 0;
DSU(int n){
components = n;
for(int i=0; i < n; i++){
par.push_back(i);
chi.push_back(1);
}
}
int getP(int n){
... | 1 | 0 | ['Union Find', 'C++'] | 0 |
properties-graph | Best and easy solution to get an idea how to approach such Questions | best-and-easy-solution-to-get-an-idea-ho-3sq2 | IntuitionComplexity
Time complexity: O(n² * m)
Space complexity:
Adjacency list: O(n²)
Visited array: O(n)
HashSets: O(m)
Recursion stack: O(n)
Overall Space | cocwarrior16112004 | NORMAL | 2025-03-23T04:21:45.029844+00:00 | 2025-03-23T04:21:45.029844+00:00 | 37 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
just follow the question , use hashSet to find distinct common elements in the array , and after that connect those nodes to each other by adding them to the adj list , and its done.
The graph is completed , now apply simple bfs an... | 1 | 0 | ['Array', 'Hash Table', 'Depth-First Search', 'Java'] | 0 |
properties-graph | Easy to Understand - Queue + BFS - Python/Java/C++ | easy-to-understand-queue-bfs-pythonjavac-tq2v | IntuitionApproachComplexity
Time complexity:
Space complexity:
Note:While the Python and Java code execute successfully, the C++ code results in a TLE. Yet, wh | cryandrich | NORMAL | 2025-03-23T04:13:20.817615+00:00 | 2025-03-23T04:13:20.817615+00:00 | 13 | 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)$$ -->
## Note:
... | 1 | 0 | ['Breadth-First Search', 'Queue', 'C++', 'Java', 'Python3'] | 0 |
properties-graph | python code: it's work | python-code-its-work-by-bhav5sh-0e3w | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Bhav5sh | NORMAL | 2025-03-23T04:10:38.694951+00:00 | 2025-03-23T04:10:38.694951+00:00 | 35 | 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 | ['Hash Table', 'Breadth-First Search', 'Python3'] | 0 |
properties-graph | DSU || HashSet || Java | dsu-hashset-java-by-akshay_kadamm-dhta | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Akshay_Kadamm | NORMAL | 2025-03-23T04:09:07.695553+00:00 | 2025-03-23T04:09:07.695553+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:
<!-- 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 |
properties-graph | 🚀🚀 Easy way 🔥3493. Properties Graph 👇 | easy-way-3493-properties-graph-by-vanshn-s09k | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Vanshnigam | NORMAL | 2025-03-23T04:06:48.399742+00:00 | 2025-03-23T04:06:48.399742+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 | ['Greedy', 'Depth-First Search', 'Breadth-First Search', 'Union Find', 'Graph', 'Ordered Set', 'Java'] | 0 |
properties-graph | Easy Java Solution | easy-java-solution-by-vermaanshul975-7k5v | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | vermaanshul975 | NORMAL | 2025-03-23T04:06:03.551976+00:00 | 2025-03-23T04:06:33.981312+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 |
properties-graph | Java Disjoint Set Union | java-disjoint-set-union-by-adityachauhan-zycr | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | adityachauhan_27 | NORMAL | 2025-03-23T04:05:24.661987+00:00 | 2025-03-23T04:05:24.661987+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 | ['Union Find', 'Java'] | 0 |
properties-graph | Java | Set and DFS - Graph | java-set-and-dfs-graph-by-pankajj_42-b1cy | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Pankajj_42 | NORMAL | 2025-03-23T04:04:44.201885+00:00 | 2025-03-23T04:04:44.201885+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
`... | 1 | 0 | ['Java'] | 0 |
properties-graph | Easy C++ solution✅| comments added for explanation✅ | easy-c-solution-comments-added-for-expla-8p27 | Code | procrastinator_op | NORMAL | 2025-03-23T04:04:30.342519+00:00 | 2025-03-23T04:04:30.342519+00:00 | 43 | false |
# Code
```cpp []
// standard dsu template
class disjoint{
//for 0 based indexing
vector<int> rank;
vector<int> parent;
vector<int> size;
public:
disjoint(int n){
rank.resize(n,0);
size.resize(n,1);
parent.resize(n,0);
for (int i=0;i<n;i++){
parent... | 1 | 0 | ['C++'] | 0 |
properties-graph | 🚀🚀 Easy way 🔥3493. Properties Graph 👇 | easy-way-3493-properties-graph-by-vanshn-k5fq | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Vanshnigam | NORMAL | 2025-03-23T04:04:11.545949+00:00 | 2025-03-23T04:04:11.545949+00:00 | 31 | 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'] | 1 |
properties-graph | || ✅#DAY_64th_Of_Daily_Coding✅|| | day_64th_of_daily_coding-by-coding_with_-4m30 | JAI SHREE DATNA🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏Code | Coding_With_Star | NORMAL | 2025-03-23T04:02:11.929354+00:00 | 2025-03-23T04:05:32.425457+00:00 | 26 | false | # JAI SHREE DATNA🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
# Code
```cpp []
class Solution {
public:
class DSU {
public:
vector<int> parent, rank;
DSU(int size) {
parent.resize(size);
rank.resize(size, 1);
for (int i = 0; i < size; i++) {
parent[i... | 1 | 0 | ['C++', 'Java'] | 1 |
properties-graph | Union Find || Disjoint Set || O(n^2*m) || Faster than 99% || Clean Java Code | union-find-disjoint-set-on2m-faster-than-x0qe | Complexity
Time complexity: O(n2∗m)
Space complexity: O(n∗m)
Code | youssef1998 | NORMAL | 2025-03-31T21:45:49.558162+00:00 | 2025-03-31T21:45:49.558162+00:00 | 1 | false | # Complexity
- Time complexity: $$O(n^2*m)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: $$O(n*m)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```java []
class DisjointSet {
private final int[] root;
private final int[] rank;
private int count;
public ... | 0 | 0 | ['Array', 'Union Find', 'Graph', 'Java'] | 0 |
properties-graph | Java | JavaScript | TypeScript | C++ | C# | Kotlin | Go Solution. | java-javascript-typescript-c-c-kotlin-go-aazu | null | LachezarTsK | NORMAL | 2025-03-31T17:28:04.612744+00:00 | 2025-03-31T17:48:15.853026+00:00 | 2 | false | ```Java []
public class Solution {
private static final int BIT_SET_SUBGROUPS = 2;
private static final int[] RANGE_OF_VALUES = {1, 100};
private int minNumberOfUniqueValueConnections;
public int numberOfComponents(int[][] properties, int minNumberOfUniqueValueConnections) {
this.minNumberOfUn... | 0 | 0 | ['C++', 'Java', 'Go', 'TypeScript', 'Kotlin', 'JavaScript', 'C#'] | 0 |
properties-graph | 12-line union find + bit masks, beats 99.65% | 12-line-union-find-bit-masks-beats-9965-b4m0f | Complexity
Time complexity: O(m∗n)
Space complexity: O(n)
Submissionhttps://leetcode.com/problems/properties-graph/submissions/1591932651/Code | dsapelnikov | NORMAL | 2025-03-31T10:53:35.931739+00:00 | 2025-03-31T10:53:35.931739+00:00 | 1 | false | # Complexity
- Time complexity: $$O(m*n)$$
- Space complexity: $$O(n)$$
# Submission
https://leetcode.com/problems/properties-graph/submissions/1591932651/
# Code
```python3 []
class Solution:
def numberOfComponents(self, properties: List[List[int]], k: int) -> int:
# Union find: parents + parent getter w... | 0 | 0 | ['Python3'] | 0 |
properties-graph | easiest java code !....... | easiest-java-code-by-coder_neeraj123-zga4 | IntuitionApproachwe have to build the graph with the common elements of the two selected arrays , so iterate over the 2d array and select two arrays properties | coder_neeraj123 | NORMAL | 2025-03-31T07:25:38.338029+00:00 | 2025-03-31T07:25:38.338029+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->simply building the graph and counting the connected component
# Approach
<!-- Describe your approach to solving the problem. -->
we have to build the graph with the common elements of the two selected arrays , so iterate over the 2d array... | 0 | 0 | ['Java'] | 0 |
properties-graph | Use sets to find edge condition and DSU to get no. of components | use-sets-to-find-edge-condition-and-dsu-xrcs0 | IntuitionUse sets to find edge condition and DSU to get no. of componentsCode | akshar_ | NORMAL | 2025-03-30T08:16:33.871287+00:00 | 2025-03-30T08:16:33.871287+00:00 | 3 | false | # Intuition
Use sets to find edge condition and DSU to get no. of components
# Code
```cpp []
class Solution {
public:
class DSU {
public:
int n;
vector<int> parent, rank;
DSU(int _n) {
n = _n;
parent.resize(n);
rank.resize(n, 1);
for (... | 0 | 0 | ['Strongly Connected Component', 'C++'] | 0 |
properties-graph | C++ 79 ms | c-79-ms-by-eridanoy-7x07 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | eridanoy | NORMAL | 2025-03-29T21:50:50.419211+00:00 | 2025-03-29T21:50:50.419211+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 |
properties-graph | Javascript union find 685ms | javascript-union-find-685ms-by-henrychen-ex1c | null | henrychen222 | NORMAL | 2025-03-29T16:08:58.695157+00:00 | 2025-03-29T16:08:58.695157+00:00 | 1 | false |
```
function DJSet(n) {
let p = Array(n).fill(-1);
return { find, union, count, equiv, par, grp }
function find(x) {
return p[x] < 0 ? x : p[x] = find(p[x]);
}
function union(x, y) {
x = find(x);
y = find(y);
if (x == y) return false;
if (p[x] < p[y]) [x, y] ... | 0 | 0 | ['Union Find', 'JavaScript'] | 0 |
properties-graph | union-find with path compression | union-find-with-path-compression-by-lamb-lmeu | Intuition
typical union-find with path compression
brute force to check edge/connection between two nodes/properties
Code | lambdacode-dev | NORMAL | 2025-03-29T01:21:57.485628+00:00 | 2025-03-29T01:21:57.485628+00:00 | 3 | false | # Intuition
- typical union-find with path compression
- brute force to check edge/connection between two nodes/properties
# Code
```cpp []
class Solution {
public:
int numberOfComponents(vector<vector<int>>& properties, int k) {
int n = properties.size();
int m = properties[0].size();
ve... | 0 | 0 | ['C++'] | 0 |
properties-graph | Brute force to make edges and then graph visit | brute-force-to-make-edges-and-then-graph-ncft | Intuition
brute force to check number of common numbers between two properties to make an edge if >= k. This takes < 100*100*100 steps.
graph visited on the adj | lambdacode-dev | NORMAL | 2025-03-29T00:59:11.521890+00:00 | 2025-03-29T00:59:11.521890+00:00 | 4 | false | # Intuition
- brute force to check number of common numbers between two properties to make an edge if `>= k`. This takes `< 100*100*100` steps.
- graph visited on the adjacent list.
- use `vector` instead of `unordered_map/set` as size is only `< 100`
# Code
```cpp []
class Solution {
public:
int numberOfCompon... | 0 | 0 | ['C++'] | 0 |
properties-graph | [C++] Union Find || Bitset | c-union-find-bitset-by-daks_05-zsvf | IntuitionThe question states that there are n nodes 0 to n-1.
Since There exists between node i to j only if intersect(properties[i], properties[j]) >= k, where | daks_05 | NORMAL | 2025-03-28T17:29:43.226656+00:00 | 2025-03-28T17:29:43.226656+00:00 | 1 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The question states that there are n nodes `0` to `n-1`.
Since There exists between node `i` to `j` only if `intersect(properties[i], properties[j]) >= k`, where `intersect(a, b) that returns the number of distinct integers common to both a... | 0 | 0 | ['Hash Table', 'Bit Manipulation', 'Union Find', 'C++'] | 0 |
properties-graph | 🔥 The Ultimate Union-Find Trick to Solve This in No Time! 🔥 | the-ultimate-union-find-trick-to-solve-t-drz0 | IntuitionImagine each property as a galaxy in space. If two galaxies share enough stars (common elements), they form a galactic cluster (connected component). O | dngzz1 | NORMAL | 2025-03-28T12:22:53.069397+00:00 | 2025-03-28T12:22:53.069397+00:00 | 5 | false | # Intuition
Imagine each property as a galaxy in space. If two galaxies share enough stars (common elements), they form a galactic cluster (connected component). Our mission? Find the number of these clusters! 🌌
How do we do that? Graph + Union-Find Magic! 🎩✨
# Approach
Graph Representation: Each property list is a... | 0 | 0 | ['TypeScript'] | 0 |
properties-graph | DSU soln | dsu-soln-by-rajanarora1999-ye04 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | rajanarora1999 | NORMAL | 2025-03-28T08:33:56.898511+00:00 | 2025-03-28T08:33:56.898511+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 |
properties-graph | simple python DFS solution | simple-python-dfs-solution-by-tejassheth-2i0m | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | TejasSheth | NORMAL | 2025-03-27T23:23:39.902250+00:00 | 2025-03-27T23:23:39.902250+00:00 | 4 | 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 | ['Array', 'Hash Table', 'Depth-First Search', 'Graph', 'Python3'] | 0 |
properties-graph | Easy C++ Union Find | Beats 88.95% | easy-c-union-find-beats-8895-by-divs_div-u5zm | IntuitionWhen Quesion asks about no. of components and edges are supposed to be formed based on some condition , Think once along the line of Union FindApproach | Divs_Divs | NORMAL | 2025-03-27T18:11:11.991316+00:00 | 2025-03-27T18:11:11.991316+00:00 | 5 | false | # Intuition
When Quesion asks about no. of components and edges are supposed to be formed based on some condition , Think once along the line of **Union Find**
# Approach
1. Write the code of Union Find , cnt is to maintain no. of comoponents. Initially there ar en components as there are no edges formed
2. Take ever... | 0 | 0 | ['Union Find', 'Graph', 'C++'] | 0 |
properties-graph | just use union find 🙂 | just-use-union-find-by-shashanksaroj-vlav | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | shashanksaroj | NORMAL | 2025-03-27T16:03:01.384932+00:00 | 2025-03-27T16:03:01.384932+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
`... | 0 | 0 | ['Java'] | 0 |
properties-graph | Easy to understand ...try once | easy-to-understand-try-once-by-chandak14-51z7 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | chandak1427 | NORMAL | 2025-03-27T08:20:41.508534+00:00 | 2025-03-27T08:20:41.508534+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 | ['Hash Table', 'Union Find', 'Graph', 'Java'] | 0 |
properties-graph | Beats 97%; Simple Counting and Storing Indices First and then DFS | beats-97-simple-counting-and-storing-ind-icvv | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Architava_Bhattacharya | NORMAL | 2025-03-26T22:21:39.271573+00:00 | 2025-03-26T22:21:39.271573+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 | ['Java'] | 0 |
properties-graph | TLE Issue Solution using minor changes | tle-issue-solution-using-minor-changes-b-bwnl | Approach
Steps to solve tle issue;
1.
instead of this:do this:2.
instead of this:do this:Complexity
Time complexity:
Space complexity:
Code | vasp0007 | NORMAL | 2025-03-26T21:20:36.536313+00:00 | 2025-03-26T21:20:36.536313+00:00 | 4 | false | # Approach
<!-- Describe your approach to solving the problem. -->
> ## **Steps to solve tle issue;**
$$1.$$
instead of this:
```
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
adj[i].push_back(j);
}
}
```
do this:
```
for(int i=0; i<n; i++){
for(int j=i+1; j<n; j++){
adj[i].push_back(j);
... | 0 | 0 | ['Depth-First Search', 'Breadth-First Search', 'Graph', 'Ordered Set', 'C++'] | 0 |
properties-graph | Python | python-by-aravindankathi-0k5g | Complexity
Time complexity: N*N
Space complexity: O(N)
Code | aravindankathi | NORMAL | 2025-03-26T19:01:03.955616+00:00 | 2025-03-26T19:01:03.955616+00:00 | 1 | false |
# Complexity
- Time complexity: N*N
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```python3 []
class Solution:
def numberOfComponents(self, properties: List[List[int]], k: int) -> int:
def intersect(a... | 0 | 0 | ['Python3'] | 0 |
properties-graph | Python - short brute force with DFS | python-short-brute-force-with-dfs-by-ant-jj05 | null | Ante_ | NORMAL | 2025-03-26T15:47:51.167614+00:00 | 2025-03-26T15:47:51.167614+00:00 | 2 | false | ```
class Solution:
def numberOfComponents(self, p, k):
props, g, n, res, seen = {i: set(a) for i, a in enumerate(p)}, defaultdict(set), len(p), 0, set()
{g[i].add(j) or g[j].add(i) for i, j in combinations(range(n), 2) if len(props[i] & props[j]) >= k}
def dfs(node):
seen.add(no... | 0 | 0 | ['Array', 'Hash Table', 'Depth-First Search', 'Python3'] | 0 |
properties-graph | Easiest solution | easiest-solution-by-markandey_kumar-lsa1 | IntuitiondfsApproach
Find the intersection in both arrays and then form the list graph
Now check no of disconnected graph that will be answer
Code | markandey_kumar | NORMAL | 2025-03-26T14:55:45.949407+00:00 | 2025-03-26T14:55:45.949407+00:00 | 1 | false | # Intuition
dfs
# Approach
1. Find the intersection in both arrays and then form the list graph
2. Now check no of disconnected graph that will be answer
# Code
```java []
class Solution {
int intersect(int[] A, int[] B){
Set<Integer> set = new HashSet<>();
int count = 0;
for(int x : A) se... | 0 | 0 | ['Java'] | 0 |
properties-graph | Easiest solution using java | easiest-solution-using-java-by-markandey-wybp | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | markandey_kumar | NORMAL | 2025-03-26T14:52:42.447040+00:00 | 2025-03-26T14:52:42.447040+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 |
properties-graph | DSU | Easy C++ Solution | dsu-easy-c-solution-by-krishiiitp-ikg7 | Code | krishiiitp | NORMAL | 2025-03-26T11:27:46.361888+00:00 | 2025-03-26T11:28:05.506820+00:00 | 3 | false | # Code
```cpp []
class DisjointSet {
private:
vector < int > parent, rank;
public:
DisjointSet (int n) {
parent.resize(n, 0);
rank.resize(n, 0);
for (int i = 0; i < n; i ++) {
parent[i] = i;
}
}
int findUp(int node) {
if (parent[node] == node) ... | 0 | 0 | ['Array', 'Union Find', 'Graph', 'C++'] | 0 |
properties-graph | Python beats 99%. Union Find + Bit Set | python-beats-99-union-find-bit-set-by-te-np8y | IntuitionWhen a problem asks for the number of connected components, union-find should be at the top of your list for things to try. This problem is asking you | tet | NORMAL | 2025-03-26T09:12:11.350565+00:00 | 2025-03-26T09:12:11.350565+00:00 | 3 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
When a problem asks for the number of connected components, union-find should be at the top of your list for things to try. This problem is asking you to build a graph where each node is a set of integers and there is an edge between every ... | 0 | 0 | ['Bit Manipulation', 'Union Find', 'Python', 'Python3'] | 0 |
properties-graph | easy cpp solution using bitset and DSU | easy-cpp-solution-using-bitset-and-dsu-b-kk5h | Code | singlaarshit | NORMAL | 2025-03-25T12:34:41.444211+00:00 | 2025-03-25T12:34:41.444211+00:00 | 2 | false |
# Code
```cpp []
class DSU {
public:
vector<int> rank, parent;
DSU(int n) {
rank.resize(n + 1, 0);
parent.resize(n + 1);
for (int i = 0; i <= n; i++) {
parent[i] = i;
}
}
int find(int node) {
if (node == parent[node]) {
return node;
... | 0 | 0 | ['C++'] | 0 |
properties-graph | Contest - 442 || Question-2 | contest-442-question-2-by-sajaltiwari007-hetw | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | sajaltiwari007 | NORMAL | 2025-03-25T10:21:39.269696+00:00 | 2025-03-25T10:21:39.269696+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
`... | 0 | 0 | ['Union Find', 'Java'] | 0 |
properties-graph | C++ | c-by-srv-er-nnfg | Code | srv-er | NORMAL | 2025-03-25T08:32:36.539537+00:00 | 2025-03-25T08:32:36.539537+00:00 | 6 | false |
# Code
```cpp []
class Solution {
public:
bool isIntersected(vector<int> property_1, vector<int> property_2, int k) {
bitset<101> mask_1, mask_2;
for (auto& i : property_1)
mask_1.set(i);
for (auto& i : property_2)
mask_2.set(i);
mask_1 &= mask_2;
in... | 0 | 0 | ['C++'] | 0 |
properties-graph | Using Two Set and Straightforward BFS Traversal | using-two-set-and-straightforward-bfs-tr-vqas | Approach1. Common Elements Calculation:
The commonElement method uses two sets to track the elements of the two arrays. It then counts the number of common elem | hokteyash | NORMAL | 2025-03-25T08:17:30.006642+00:00 | 2025-03-25T08:17:30.006642+00:00 | 2 | false | # Approach
### 1. Common Elements Calculation:
- The commonElement method uses two sets to track the elements of the two arrays. It then counts the number of common elements between the two sets.
### 2. Graph Construction:
- An adjacency list is created to represent the graph. For each pair of properties, if the num... | 0 | 0 | ['Breadth-First Search', 'Graph', 'Ordered Set', 'Java'] | 0 |
properties-graph | UnionFind | unionfind-by-ya_ah-9hcy | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | ya_ah | NORMAL | 2025-03-25T01:49:01.040201+00:00 | 2025-03-25T01:49:01.040201+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 |
properties-graph | Python || union Find | python-union-find-by-vilaparthibhaskar-hh2y | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | vilaparthibhaskar | NORMAL | 2025-03-24T23:50:03.506604+00:00 | 2025-03-24T23:50:03.506604+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
`... | 0 | 0 | ['Array', 'Hash Table', 'Union Find', 'Graph', 'Python3'] | 0 |
properties-graph | UnionFind | unionfind-by-linda2024-ukx2 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | linda2024 | NORMAL | 2025-03-24T22:26:45.941687+00:00 | 2025-03-24T22:26:45.941687+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:
<!-- 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 |
properties-graph | transfer vectors in unordered_set + BFS (C++) | transfer-vectors-in-unordered_set-bfs-c-pz3h1 | ApproachTransfer vectors in properties to unordered_set in order to efficiently find edges in graph prapering process, after that just do bfs over the graph in | xelladze | NORMAL | 2025-03-24T20:24:32.159098+00:00 | 2025-03-24T20:26:05.930847+00:00 | 2 | false | # Approach
<!-- Describe your approach to solving the problem. -->
Transfer vectors in properties to unordered_set<int> in order to efficiently find edges in graph prapering process, after that just do bfs over the graph in order to find connected components.
# Complexity
- Time complexity:O(N)
<!-- Add your time comp... | 0 | 0 | ['C++'] | 0 |
properties-graph | Java || DFS || Beats 100% | java-dfs-beats-100-by-dipankarsethi3012-l95i | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | dipankarsethi3012 | NORMAL | 2025-03-24T17:24:11.697633+00:00 | 2025-03-24T17:24:11.697633+00:00 | 4 | 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 |
properties-graph | Easy JAVA Solution using Sets and BFS | easy-java-solution-using-sets-and-bfs-by-kk41 | Code | Debrup7703 | NORMAL | 2025-03-24T13:49:01.807764+00:00 | 2025-03-24T13:49:01.807764+00:00 | 1 | false |
# Code
```java []
class Solution {
public int numberOfComponents(int[][] properties, int k) {
int n=properties.length;
List<List<Integer>> adj=new ArrayList<>();
for(int i=0;i<=n;i++) adj.add(new ArrayList<Integer>());
HashMap<Integer,HashSet<Integer>> map=new HashMap<>();
f... | 0 | 0 | ['Hash Table', 'Breadth-First Search', 'Graph', 'Java'] | 0 |
properties-graph | 8 lines scala disjoint-set / union-find solution | 8-lines-scala-disjoint-set-union-find-so-mgfj | null | vititov | NORMAL | 2025-03-24T11:24:19.758311+00:00 | 2025-03-24T11:24:19.758311+00:00 | 1 | false | ```scala []
object Solution {
import scala.util.chaining._
def numberOfComponents(properties: Array[Array[Int]], k: Int): Int = {
val djs = properties.indices.to(Array)
def root(i:Int): Int = if(djs(i)==i) i else root(djs(i)).tap(djs(i) = _)
def join(i:Int)(j:Int) = (djs(root(j))=root(i))
properties... | 0 | 0 | ['Hash Table', 'Greedy', 'Union Find', 'Graph', 'Scala'] | 0 |
properties-graph | 😀100% User Beat | 💡 DFS | Java | 100-user-beat-dfs-java-by-s_a_m2003-bh80 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | s_a_m2003 | NORMAL | 2025-03-24T10:57:32.722390+00:00 | 2025-03-24T10:57:32.722390+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 | ['Depth-First Search', 'Graph', 'Java'] | 0 |
properties-graph | Simple bitset + dfs || c++ | simple-bitset-dfs-c-by-subhamchauhan1100-ov1s | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | subhamchauhan1100 | NORMAL | 2025-03-24T09:43:41.959474+00:00 | 2025-03-24T09:43:41.959474+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
`... | 0 | 0 | ['C++'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.