Skip to content

Commit 6477805

Browse files
committed
updated
1 parent 725c0ad commit 6477805

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

dsa-solutions/lc-solutions/0000-0099/0017-letter-combinations-of-a-phone-number.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,4 +314,4 @@ Here's a step-by-step algorithm for generating all possible letter combinations
314314
- Call the backtracking function with the initial index set to 0 and an empty string as the initial combination.
315315
- Return the list of combinations.
316316

317-
This algorithm ensures that all possible combinations are generated by exploring all valid paths through backtracking.
317+
This algorithm ensures that all possible combinations are generated by exploring all valid paths through backtracking.

dsa-solutions/lc-solutions/0200-0299/0229-Majority-Element.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ Output: [1,2]
3434

3535
### Constraints
3636

37-
- $1 \leq nums.length \leq 5 \times 10^4$
38-
- $-10^9 \leq nums[i] \leq 10^9$
39-
37+
- `1 <= nums.length <= 5 * 10^4`
38+
- `-10^9 <= nums[i] <= 10^9`
4039
### Approach
4140

4241
To solve this problem, we can use the Boyer-Moore Voting Algorithm, which efficiently finds the majority elements in linear time and constant space. The algorithm can be summarized in the following steps:
@@ -52,9 +51,7 @@ To solve this problem, we can use the Boyer-Moore Voting Algorithm, which effici
5251

5352
#### Code in Different Languages
5453

55-
<Tabs>
56-
<TabItem value="cpp" label="C++">
57-
<SolutionAuthor name="@Vipullakum007"/>
54+
### C++ Solution
5855
```cpp
5956
#include <vector>
6057
#include <iostream>
@@ -106,9 +103,9 @@ int main() {
106103
cout << num << " ";
107104
}
108105
}
109-
</TabItem>
110-
<TabItem value="java" label="Java">
111-
<SolutionAuthor name="@Vipullakum007"/>
106+
```
107+
### Java Solution
108+
```java
112109
import java.util.*;
113110
114111
public class MajorityElementII {
@@ -156,9 +153,10 @@ public class MajorityElementII {
156153
System.out.println(result);
157154
}
158155
}
159-
</TabItem>
160-
<TabItem value="python" label="Python">
161-
<SolutionAuthor name="@Vipullakum007"/>
156+
```
157+
### Python Solution
158+
159+
```python
162160
def majorityElement(nums):
163161
n = len(nums)
164162
if n == 0:
@@ -200,20 +198,18 @@ def majorityElement(nums):
200198

201199
nums = [3, 2, 3]
202200
print(majorityElement(nums))
203-
</TabItem>
204-
</Tabs>
201+
```
205202

206203
### Complexity Analysis
207204

208205
### Time Complexity: O(N)
209-
**Reason:** We perform two passes through the array, each requiring linear time.
206+
>Reason: We perform two passes through the array, each requiring linear time.
210207
211208
**Space Complexity:** O(1)
212-
**Reason:** We use a constant amount of extra space for counters and candidates.
209+
>Reason: We use a constant amount of extra space for counters and candidates.
213210
214-
This solution efficiently finds all elements that appear more than ⌊ n/3 ⌋ times using the Boyer-Moore Voting Algorithm. The time complexity is linear, and the space complexity is constant, making it suitable for large input sizes.
211+
>This solution efficiently finds all elements that appear more than ⌊ n/3 ⌋ times using the Boyer-Moore Voting Algorithm. The time complexity is linear, and the space complexity is constant, making it suitable for large input sizes.
215212
216213
#### References
217214
**LeetCode Problem:** Majority Element II
218215
**Authors GeeksforGeeks Profile:** Vipul lakum
219-
```

0 commit comments

Comments
 (0)