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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
construct-k-palindrome-strings | JAVA || SIMPLE AND EASY SOLUTION || oddCounts logic || TRY WITH forEach LOOP | java-simple-and-easy-solution-oddcounts-sspvl | IntuitionUSING forEach loop it will reduce the runtime.ApproachComplexity
Time complexity:
Space complexity:
Code | kavi_k | NORMAL | 2025-01-11T06:22:11.598064+00:00 | 2025-01-11T06:55:11.751636+00:00 | 29 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
USING forEach loop it will reduce the runtime.
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your spac... | 2 | 0 | ['Java'] | 0 |
construct-k-palindrome-strings | Beginner friendly 💯 💯 || Clean code ✅✅✅ | beginner-friendly-clean-code-by-prabhas_-h0ec | IntuitionYou want to check if it's possible to rearrange the string s into exactly k palindrome substrings.Observations:
A palindrome reads the same backward a | prabhas_rakurthi | NORMAL | 2025-01-11T06:11:56.705735+00:00 | 2025-01-11T06:11:56.705735+00:00 | 30 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
You want to check if it's possible to rearrange the string s into exactly k palindrome substrings.
# **Observations**:
- A palindrome reads the same backward as forward.
**For a string to be a palindrome:**
- At most one character can ha... | 2 | 0 | ['Hash Table', 'Java'] | 0 |
construct-k-palindrome-strings | 🔥 Very Easy Detailed Solution || 🔥 Beats 100% || 🎯 Three Approaches | very-easy-detailed-solution-beats-100-th-hwg0 | Approach 1 : Frequency counting and condition checking based on odd/even characters
Count Character Frequencies:
The freq array keeps track of the frequency o | chaturvedialok44 | NORMAL | 2025-01-11T05:56:12.300778+00:00 | 2025-01-11T05:56:12.300778+00:00 | 35 | false | # Approach 1 : Frequency counting and condition checking based on odd/even characters
<!-- Describe your approach to solving the problem. -->
1. **Count Character Frequencies:**
- The freq array keeps track of the frequency of each character in the string s.
- The loop for(int i=0; i<n; i++) iterates through th... | 2 | 1 | ['Array', 'Hash Table', 'Math', 'String', 'Ordered Map', 'Counting', 'Java'] | 2 |
construct-k-palindrome-strings | easy intuition based solution runs in O(n) with hash table | easy-intuition-based-solution-runs-in-on-gvit | IntuitionAny even occurence can be easily be used to form a new palindrome.
What about characters with odd frequency ?ApproachCount the total occurences of char | sanky_20 | NORMAL | 2025-01-11T05:53:41.529564+00:00 | 2025-01-11T05:53:41.529564+00:00 | 5 | false | # Intuition
Any even occurence can be easily be used to form a new palindrome.
What about characters with odd frequency ?
# Approach
Count the total occurences of characters with odd freqquencies . if this value say count
count <= k then we can form that many odd length palindromic strings
ex -: s = "annabelle" k = 3... | 2 | 0 | ['Hash Table', 'Counting', 'C++'] | 0 |
construct-k-palindrome-strings | Solution in C | solution-in-c-by-vickyy234-3k87 | Code | vickyy234 | NORMAL | 2025-01-11T05:40:29.003165+00:00 | 2025-01-11T05:40:29.003165+00:00 | 23 | false | # Code
```c []
bool canConstruct(char* s, int k) {
if(k > strlen(s)) return false;
if(k == strlen(s)) return true;
int *freq=calloc(sizeof(int),26);
for(int i=0;i<strlen(s);i++){
freq[s[i]-'a']++;
}
int oddcount=0;
for(int i=0;i<26;i++){
if(freq[i]%2!=0) oddcount++;
... | 2 | 0 | ['C'] | 0 |
construct-k-palindrome-strings | Easy One for loop solution | easy-one-for-loop-solution-by-samir04-lwet | null | Samir04 | NORMAL | 2025-01-11T05:40:02.380785+00:00 | 2025-01-11T05:40:02.380785+00:00 | 53 | false | ```python3 []
class Solution:
def canConstruct(self, s: str, k: int) -> bool:
if len(s)<k:
return False
hashmap = Counter(s)
count = 0
for key, value in hashmap.items():
if value % 2 == 1:
count+=1
return count<=k
``` | 2 | 0 | ['Hash Table', 'Counting', 'Python3'] | 0 |
construct-k-palindrome-strings | Java || 3ms || 100 %beat use Frequency Array || | java-3ms-100-beat-use-frequency-array-by-yzs6 | IntuitionApproachget frequence Count the odd number and compare to k return AnsewerComplexity
Time complexity:
o(2*n)
Space complexity:
o(n)
Code | sathish-77 | NORMAL | 2025-01-11T05:37:09.079791+00:00 | 2025-01-11T05:37:09.079791+00:00 | 34 | false | # Intuition
# Approach
get frequence Count the odd number and compare to k return Ansewer
# Complexity
- Time complexity:
o(2*n)
- Space complexity:
o(n)
# Code
```java []
class Solution {
public boolean canConstruct(String s, int k) {
if(s.length()<k) return false;
int[] arr=new int[26];
... | 2 | 0 | ['Hash Table', 'String', 'Counting Sort', 'Java'] | 0 |
construct-k-palindrome-strings | Easy Solution | Frequency | Greedy | C++ | easy-solution-frequency-greedy-c-by-mano-4q2o | IntuitionBy considering the properties of the palindrome, we could try to eliminate the cases that could not possibly lead to the solution.
An even length of th | manojithbhat | NORMAL | 2025-01-11T05:32:17.086418+00:00 | 2025-01-11T05:32:17.086418+00:00 | 24 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
By considering the properties of the palindrome, we could try to eliminate the cases that could not possibly lead to the solution.
1. An even length of the particular character do not cause the problem.
2. Odd length of character can only h... | 2 | 0 | ['Hash Table', 'String', 'Greedy', 'Counting', 'C++'] | 0 |
construct-k-palindrome-strings | C# Solution for Construct K Palindrome Strings Problem | c-solution-for-construct-k-palindrome-st-28m8 | IntuitionThe problem involves determining whether all characters in a string s can be used to construct exactly k palindrome strings. The key observations are: | Aman_Raj_Sinha | NORMAL | 2025-01-11T05:24:26.238630+00:00 | 2025-01-11T05:24:26.238630+00:00 | 27 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem involves determining whether all characters in a string s can be used to construct exactly k palindrome strings. The key observations are:
1. Odd Frequency Characters: A palindrome can have at most one character with an odd freq... | 2 | 0 | ['C#'] | 0 |
construct-k-palindrome-strings | ✅🔥BEATS 100%🔥 || Beginner Friendly || Construct K Palindrome Strings 💡|| CONCISE CODE ✅ | beats-100-beginner-friendly-construct-k-n8yx8 | IntuitionApproachComplexity
Time complexity: O(n)
Space complexity: O(1)
Code | vanshdvn2505 | NORMAL | 2025-01-11T05:11:51.206027+00:00 | 2025-01-11T05:11:51.206027+00:00 | 19 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->... | 2 | 0 | ['C++'] | 1 |
construct-k-palindrome-strings | Easy Solution in C | easy-solution-in-c-by-sathurnithy-kdf1 | Code | Sathurnithy | NORMAL | 2025-01-11T03:47:37.605904+00:00 | 2025-01-11T04:00:53.455046+00:00 | 17 | false | # Code
```c []
#define ALPHABETS 26
bool canConstruct(char* s, int k) {
if(strlen(s) < k) return false;
if(strlen(s) == k) return true;
int* freqArr = calloc(ALPHABETS, sizeof(int));
for(int i=0; i<strlen(s); i++)
freqArr[s[i] - 'a']++;
int oddFreq = 0;
for(int i=0; i<ALPHABETS; i... | 2 | 0 | ['String', 'Greedy', 'C', 'Counting'] | 0 |
construct-k-palindrome-strings | Optimised Odd Balancer | constant space | optimised-odd-balancer-constant-space-by-zozk | IntuitionWe want to check if it's possible to partition the given string into exactly k non-empty substrings such that each substring is a palindrome. This esse | sachin1604 | NORMAL | 2025-01-11T03:43:28.367186+00:00 | 2025-01-11T03:43:28.367186+00:00 | 32 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We want to check if it's possible to partition the given string into exactly k non-empty substrings such that each substring is a palindrome. This essentially boils down to counting how many characters have an odd frequency.
# Approach
<!--... | 2 | 0 | ['C++'] | 0 |
construct-k-palindrome-strings | Simple Approach || Easy to Beats 100% || | simple-approach-easy-to-beats-100-by-raj-sth1 | Firstly ,Thanks for come in my solution :)Complexity
Time complexity:O(N)
Space complexity:O(N)
Code | Rajpatel16 | NORMAL | 2025-01-11T03:40:26.725966+00:00 | 2025-01-11T03:40:26.725966+00:00 | 30 | false | **Firstly ,Thanks for come in my solution :)**
# 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:
bool canConstruct(string s, int k) {
if(s.size(... | 2 | 0 | ['Hash Table', 'String', 'Greedy', 'Counting', 'C++'] | 0 |
construct-k-palindrome-strings | Beats 100%✅ | Counting | Simple Solution With Added Comments | Time Complexity O(n) | beats-100-counting-simple-solution-with-iope0 | IntuitionThe idea behind this solution is that if there are more than k characters then it is not possible to make k palindromes, If this is not the case, then | nvdpsaluja | NORMAL | 2025-01-11T03:08:36.050383+00:00 | 2025-01-11T03:28:49.907532+00:00 | 29 | false | # Intuition
The idea behind this solution is that if there are more than k characters then it is not possible to make k palindromes, If this is not the case, then the count of characters which occured odd times must be less than k.
# Complexity
- Time complexity:
O(n)
- Space complexity:
O(26)
# Code
```cpp []
cla... | 2 | 0 | ['Counting', 'C++'] | 0 |
construct-k-palindrome-strings | Solution without HashTable || java || C++ | solution-without-hashtable-java-c-by-dsu-m9kf | IntuitionTo form a single palindrome string, either
it should have a single odd character or
it should have all characters with even frequencies
To form k palin | dsuryaprakash89 | NORMAL | 2025-01-11T02:39:36.639077+00:00 | 2025-01-11T02:39:36.639077+00:00 | 6 | false | # Intuition
To form a single palindrome string, either
- it should have a single odd character or
- it should have all characters with even frequencies
To form `k` palindromes, the total number of characters with odd frequencies should be at most `k`.
- Each palindrome can have one character with an odd frequency (w... | 2 | 0 | ['Counting', 'C++', 'Java'] | 0 |
construct-k-palindrome-strings | Beats 100% - DP - O(n) - count number of odd characters | beats-100-dp-on-count-number-of-odd-char-98ey | Intuition
count number of odd characters
Approach
check len(s) vs k
counting number of each character
count number of odd characters countOdd
compare countOdd | luudanhhieu | NORMAL | 2025-01-11T00:51:58.900872+00:00 | 2025-01-11T00:51:58.900872+00:00 | 70 | false | # Intuition
- count number of odd characters
# Approach
- check len(s) vs k
- counting number of each character
- count number of odd characters `countOdd`
- compare countOdd vs k to get result
# Complexity
- Time complexity: O(n))
- Space complexity: O(1)
# Code
```golang []
func canConstruct(s string, k int) bo... | 2 | 0 | ['Go'] | 1 |
construct-k-palindrome-strings | C++ 100% EASY TO UNDERSTAND TLDE; | c-100-easy-to-understand-tlde-by-sainadt-aut0 | IntuitionCHECK CODE COMMENTSApproachComplexity
Time complexity: O(∣s∣)
Space complexity: O(1)
Code | sainadth | NORMAL | 2025-01-11T00:38:11.827959+00:00 | 2025-01-11T00:38:11.827959+00:00 | 16 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
CHECK CODE COMMENTS
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity: $$O(|s|)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: $$O(1)$$
<!-- Add your space compl... | 2 | 0 | ['Array', 'C++'] | 0 |
construct-k-palindrome-strings | Swift💯1liner w/ bits; Fastest: 0ms | swift1liner-w-bits-fastest-0ms-by-upvote-s3ae | One-Liner using Bits, terse (accepted answer)
Return true if s can be partitioning into at least k sections and the number of odd-count letters is <= k. | UpvoteThisPls | NORMAL | 2025-01-11T00:32:03.419693+00:00 | 2025-01-11T00:32:03.419693+00:00 | 38 | false | **One-Liner using Bits, terse (accepted answer)**
Return `true` if `s` can be partitioning into at least `k` sections and the number of odd-count letters is <= `k`.
```
class Solution {
func canConstruct(_ s: String, _ k: Int) -> Bool {
s.count>=k && s.utf8.reduce(0){$0^(1<<($1-97))}.nonzeroBitCount<=k
}
}
``` | 2 | 0 | ['Swift'] | 2 |
construct-k-palindrome-strings | C++ | Odd Even Frequency | c-odd-even-frequency-by-ahmedsayed1-r74g | The best construction of palindrome string contains all chars occurrence even time or at most 1 char occurrence odd timesCode | AhmedSayed1 | NORMAL | 2025-01-11T00:12:28.224639+00:00 | 2025-01-11T00:12:59.054455+00:00 | 53 | false | # The best construction of palindrome string contains all chars occurrence even time or at most 1 char occurrence odd times
# Code
```cpp []
class Solution {
public:
bool canConstruct(string s, int k) {
if(k > s.size())return 0;
int fre[26]{};
for(auto i : s)fre[i - 'a']++;
int odd... | 2 | 0 | ['Greedy', 'Counting', 'C++'] | 0 |
construct-k-palindrome-strings | O(1) - Most detailed explanation | o1-most-detailed-explanation-by-__phoeni-isj7 | The problem is quite simple and interesting as well. Lets start from very basic:\n\nQ. Suppose we are given a string str, and we are free to jumble the characte | __phoenixer__ | NORMAL | 2023-06-28T11:05:47.459127+00:00 | 2023-06-28T11:06:28.402261+00:00 | 149 | false | The problem is quite simple and interesting as well. Lets start from very basic:\n\n**Q.** Suppose we are given a string ```str```, and we are free to jumble the characters, and we need to tell that wheather ```str``` can be palindrome after jumbling.\n* So, we will keep a track of frequency of each character appeared ... | 2 | 0 | ['C'] | 2 |
construct-k-palindrome-strings | THIS IS HOW IT WORKS' | this-is-how-it-works-by-e8s4ca3p9e-y1zv | lets talk about the case when k<s.size() // coz it is confusing lol\n\nit means we have to do k partitions\n\nsuppose no of odd occuring characters be : o\nassu | E8S4CA3P9E | NORMAL | 2022-11-24T18:12:26.020270+00:00 | 2022-11-24T19:01:19.711266+00:00 | 208 | false | lets talk about the case when k<s.size() // coz it is confusing lol\n\nit means we have to do k partitions\n\nsuppose no of odd occuring characters be : o\nassuming o<=k\n\n----- ----- ----- ----- ----- ---- -----\nsuppose these are k partitions, of different lengths ( might be of same length too)\ni am represeting th... | 2 | 0 | [] | 1 |
construct-k-palindrome-strings | ✔ [C++ / Python3] Solution | XOR | c-python3-solution-xor-by-satyam2001-k1me | Complexity\n- Time complexity: O(n)\n- Space complexity: O(1)\n\n# Python3\n\nclass Solution:\n def canConstruct(self, S, K):\n return bin(reduce(oper | satyam2001 | NORMAL | 2022-11-14T18:36:51.942874+00:00 | 2022-11-14T18:36:51.942915+00:00 | 366 | false | # Complexity\n- Time complexity: $$O(n)$$\n- Space complexity: $$O(1)$$\n\n# Python3\n```\nclass Solution:\n def canConstruct(self, S, K):\n return bin(reduce(operator.xor, map(lambda x: 1 << (ord(x) - 97), S))).count(\'1\') <= K <= len(S)\n```\n\n# C++\n```\nclass Solution {\npublic:\n bool canConstruct(s... | 2 | 0 | ['Bit Manipulation', 'Python3'] | 1 |
construct-k-palindrome-strings | Python beats 97% with reasoning | python-beats-97-with-reasoning-by-zym199-b268 | \nclass Solution:\n def canConstruct(self, s: str, k: int) -> bool:\n \'\'\'\n For a palindrome, its odd-count character has to be less than or | zym1994815 | NORMAL | 2022-06-03T08:25:59.716078+00:00 | 2022-06-03T08:26:56.545132+00:00 | 398 | false | ```\nclass Solution:\n def canConstruct(self, s: str, k: int) -> bool:\n \'\'\'\n For a palindrome, its odd-count character has to be less than or eqaul to one. \n Then in order to get k many palindromic substrings, the number of odd-count chracters in s has to be less than\n or equal to ... | 2 | 0 | ['Python'] | 2 |
element-appearing-more-than-25-in-sorted-array | Simple Java Solution - O(n) time, O(1) space | simple-java-solution-on-time-o1-space-by-0zqf | \n public int findSpecialInteger(int[] arr) {\n int n = arr.length, t = n / 4;\n\n for (int i = 0; i < n - t; i++) {\n if (arr[i] == | anshu4intvcom | NORMAL | 2019-12-14T16:01:00.198954+00:00 | 2019-12-14T16:11:03.406388+00:00 | 10,142 | false | ```\n public int findSpecialInteger(int[] arr) {\n int n = arr.length, t = n / 4;\n\n for (int i = 0; i < n - t; i++) {\n if (arr[i] == arr[i + t]) {\n return arr[i];\n }\n }\n return -1;\n }\n``` | 203 | 3 | [] | 13 |
element-appearing-more-than-25-in-sorted-array | [4 Minute Read] Mimicking an Interview | 4-minute-read-mimicking-an-interview-by-ko1ol | In this post, I would be discussing this problem with different approaches which you would come up in an interview in the manner of increasing difficulty. I wil | dead_lock | NORMAL | 2021-08-12T09:21:12.097968+00:00 | 2021-08-18T10:36:57.142644+00:00 | 3,485 | false | In this post, I would be discussing this problem with different approaches which you would come up in an interview in the manner of increasing difficulty. I will be writting this post in such a way as if I were the person being interviewed. So, enjoy \uD83D\uDE0A\n\n<br>\n\n> **Interviewer: Given the problem [Element A... | 130 | 2 | ['Binary Tree', 'Java'] | 10 |
element-appearing-more-than-25-in-sorted-array | Java Binary Search | java-binary-search-by-poorvank-zbc5 | Since its a sorted array so i wanted to avoid linear search\n\nFind the element at position n/4\nPerform a binary search to find the first occurrence of that it | poorvank | NORMAL | 2019-12-14T16:04:16.004510+00:00 | 2019-12-14T22:58:54.841446+00:00 | 12,055 | false | Since its a sorted array so i wanted to avoid linear search\n\nFind the element at position n/4\nPerform a binary search to find the first occurrence of that item.\nPerform a binary search to find the last occurrence of that item.\nIf last-first+1 > n/4, you have your answer.\n\nRepeat that process for n/2 and 3(n/4)\n... | 129 | 9 | [] | 23 |
element-appearing-more-than-25-in-sorted-array | Concise O(logn) solution using C++ (beat 90%) | concise-ologn-solution-using-c-beat-90-b-8w6z | Because it\'s guaranteed that only one number will appear more than 25% times, that number will definitely appear at one of the three positions in the array: qu | mrjia1997 | NORMAL | 2019-12-17T12:37:37.098656+00:00 | 2019-12-17T12:37:37.098687+00:00 | 6,389 | false | Because it\'s guaranteed that only one number will appear more than 25% times, that number will definitely appear at one of the three positions in the array: quarter, half, and three quarters. We see them as candidates, and then using binary search to check each of them. \n\nTime complexity: O(logn)\nSpace complexity: ... | 106 | 1 | ['Binary Tree'] | 15 |
element-appearing-more-than-25-in-sorted-array | ✅ Beats 100% - Explained with [ Video ]- C++/Java/Python/JS - Single Pass - Visualized | beats-100-explained-with-video-cjavapyth-x0q6 | \n\n# YouTube Video Explanation:\n\nhttps://youtu.be/R2N7catcZ_I\n **If you want a video for this question please write in the comments** \n\n\uD83D\uDD25 Pleas | lancertech6 | NORMAL | 2023-12-11T02:00:49.955890+00:00 | 2023-12-11T02:36:39.146347+00:00 | 15,512 | false | \n\n# YouTube Video Explanation:\n\n[https://youtu.be/R2N7catcZ_I](https://youtu.be/R2N7catcZ_I)\n<!-- **If you want a video for this question please write in the comments** -->\n\n**... | 97 | 2 | ['Array', 'Python', 'C++', 'Java', 'JavaScript'] | 6 |
element-appearing-more-than-25-in-sorted-array | Python3 faster over98% | python3-faster-over98-by-zhangjunxu3-reej | \nclass Solution:\n\ndef findSpecialInteger(self, arr: List[int]) -> int:\nn = len(arr) // 4\nfor i in range(len(arr)):\nif arr[i] == arr[i + n]:\nreturn arr[i] | zhangjunxu3 | NORMAL | 2020-01-06T04:07:12.680115+00:00 | 2020-01-06T04:07:12.680158+00:00 | 4,454 | false | ```\nclass Solution:\n\ndef findSpecialInteger(self, arr: List[int]) -> int:\nn = len(arr) // 4\nfor i in range(len(arr)):\nif arr[i] == arr[i + n]:\nreturn arr[i]\n```\n | 63 | 7 | [] | 12 |
element-appearing-more-than-25-in-sorted-array | [Java] Binary Search with O(log(N)) solution | java-binary-search-with-ologn-solution-b-p077 | \n public int findSpecialInteger(int[] arr) {\n if (arr.length == 1) return arr[0];\n\n int length = arr.length;\n List<Integer> firstTh | MichaelBarskii | NORMAL | 2020-05-05T11:56:19.535968+00:00 | 2020-05-05T11:57:04.354942+00:00 | 3,126 | false | ```\n public int findSpecialInteger(int[] arr) {\n if (arr.length == 1) return arr[0];\n\n int length = arr.length;\n List<Integer> firstThreeQuarters =\n new ArrayList<>(Arrays.asList(arr[length / 4], arr[length / 2], arr[3 * length / 4]));\n\n for (Integer elem : firstThr... | 42 | 2 | ['Binary Tree', 'Java'] | 8 |
element-appearing-more-than-25-in-sorted-array | Python 3 (four different one-line solutions) (beats 100%) | python-3-four-different-one-line-solutio-xsa6 | ```\nclass Solution:\n def findSpecialInteger(self, A: List[int]) -> int:\n return collections.Counter(A).most_common(1)[0][0]\n\t\t\n\nfrom statistic | junaidmansuri | NORMAL | 2019-12-15T08:56:40.465228+00:00 | 2019-12-15T09:00:27.103140+00:00 | 3,317 | false | ```\nclass Solution:\n def findSpecialInteger(self, A: List[int]) -> int:\n return collections.Counter(A).most_common(1)[0][0]\n\t\t\n\nfrom statistics import mode\n\nclass Solution:\n def findSpecialInteger(self, A: List[int]) -> int:\n return mode(A)\n\n\nclass Solution:\n def findSpecialIntege... | 30 | 6 | ['Python', 'Python3'] | 4 |
element-appearing-more-than-25-in-sorted-array | 【Video】Give me 5 minutes - 2 solutions - How we think about a solution | video-give-me-5-minutes-2-solutions-how-4pqs6 | Intuition\nCalculate quarter length of input array.\n\n---\n\n# Solution Video\n\nhttps://youtu.be/bTm-6y7Ob0A\n\n\u25A0 Timeline of the video\n\n0:07 Explain a | niits | NORMAL | 2024-12-01T16:08:30.573861+00:00 | 2024-12-01T16:08:30.573890+00:00 | 672 | false | # Intuition\nCalculate quarter length of input array.\n\n---\n\n# Solution Video\n\nhttps://youtu.be/bTm-6y7Ob0A\n\n\u25A0 Timeline of the video\n\n`0:07` Explain algorithm of Solution 1\n`2:46` Coding of solution 1\n`3:49` Time Complexity and Space Complexity of solution 1\n`4:02` Step by step algorithm of solution 1\... | 28 | 0 | ['Array', 'C++', 'Java', 'Python3', 'JavaScript'] | 0 |
element-appearing-more-than-25-in-sorted-array | [JavaScript] Sliding window | javascript-sliding-window-by-greenteacak-5pfo | \n/**\n * @param {number[]} arr\n * @return {number}\n */\nvar findSpecialInteger = function(arr) {\n const ws = Math.floor(arr.length / 4);\n for (let i | GreenTeaCake | NORMAL | 2020-01-22T23:43:08.352728+00:00 | 2020-01-22T23:43:08.352777+00:00 | 983 | false | ```\n/**\n * @param {number[]} arr\n * @return {number}\n */\nvar findSpecialInteger = function(arr) {\n const ws = Math.floor(arr.length / 4);\n for (let i = 0; i < arr.length - ws; i++) {\n if (arr[i] === arr[i + ws]) {\n return arr[i];\n }\n }\n return -1;\n};\n``` | 26 | 1 | ['Sliding Window', 'JavaScript'] | 2 |
element-appearing-more-than-25-in-sorted-array | [Java/Python 3] O(n) and O(logn) codes w brief explanation and analysis. | javapython-3-on-and-ologn-codes-w-brief-jvusu | Time O(logn) binary search code similar to:\n1283. Find the Smallest Divisor Given a Threshold\n1870. Minimum Speed to Arrive on Time\n2187. Minimum Time to Com | rock | NORMAL | 2019-12-14T16:04:54.405092+00:00 | 2022-02-27T21:05:10.672442+00:00 | 2,550 | false | Time O(logn) binary search code similar to:\n[1283. Find the Smallest Divisor Given a Threshold](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold/discuss/446313/JavaPython-3-Binary-search-9-and-8-liners-w-brief-explanation-and-analysis.)\n[1870. Minimum Speed to Arrive on Time](https://leetcode... | 22 | 3 | [] | 9 |
element-appearing-more-than-25-in-sorted-array | [C++] Three Solutions | c-three-solutions-by-pankajgupta20-wq4s | 1) Hashmap Solution\n\tclass Solution {\n\tpublic:\n\t\tint findSpecialInteger(vector& arr) {\n\t\t\tunordered_map m;\n\t\t\tfor(int i = 0; i < arr.size(); i++) | pankajgupta20 | NORMAL | 2021-05-31T06:00:59.376677+00:00 | 2021-05-31T06:00:59.376720+00:00 | 1,917 | false | ##### 1) Hashmap Solution\n\tclass Solution {\n\tpublic:\n\t\tint findSpecialInteger(vector<int>& arr) {\n\t\t\tunordered_map<int, int> m;\n\t\t\tfor(int i = 0; i < arr.size(); i++){\n\t\t\t\tm[arr[i]]++;\n\t\t\t}\n\t\t\tfor(auto i : m){\n\t\t\t\tif(i.second > arr.size() / 4){\n\t\t\t\t\treturn i.first;\n\t\t\t\t}\n\t\... | 21 | 0 | ['C', 'C++'] | 1 |
element-appearing-more-than-25-in-sorted-array | Python Simple O(logn) solution | python-simple-ologn-solution-by-c_n-yyo1 | Idea: The element which appears more than 25% times in the arr must appear at either index n/4, n/2, 3*n/4, n, where n is the length of arr. So we count the amo | C_N_ | NORMAL | 2021-11-09T17:04:47.011882+00:00 | 2021-11-29T21:21:56.820734+00:00 | 1,345 | false | **Idea:** The element which appears more than 25% times in the arr must appear at either index `n/4, n/2, 3*n/4, n`, where n is the length of `arr`. So we count the amount of times the value of one of the above indexes appear in the array by using `bisect_left` (finds the first time it appears in the array) and `bisect... | 16 | 0 | ['Python3'] | 4 |
element-appearing-more-than-25-in-sorted-array | ✅✅Majority Element in Array🔥🔥 | majority-element-in-array-by-ilxamovic-wlgz | Intuition\nThe problem seems to ask for finding a "special" integer, which appears more than 25% of the time in the given array. The approach appears to use a d | ilxamovic | NORMAL | 2023-12-11T04:12:47.070740+00:00 | 2023-12-11T04:12:47.070759+00:00 | 3,640 | false | # Intuition\nThe problem seems to ask for finding a "special" integer, which appears more than 25% of the time in the given array. The approach appears to use a dictionary to count the occurrences of each element and then iterate through the dictionary to find the element that meets the criteria.\n\n# Approach\n1. Chec... | 13 | 2 | ['Java', 'Go', 'Python3', 'Rust', 'C#'] | 4 |
element-appearing-more-than-25-in-sorted-array | C++/Python frequency count vs Binary search||0ms Beats 100% | cpython-frequency-count-vs-binary-search-6c4f | Intuition\n Describe your first thoughts on how to solve this problem. \n3 different kinds of soultion arte provided.\n1 is very naive, solved this with countin | anwendeng | NORMAL | 2023-12-11T01:46:28.582322+00:00 | 2023-12-11T07:35:57.568801+00:00 | 3,566 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n3 different kinds of soultion arte provided.\n1 is very naive, solved this with counting frequency for each number; no hash table is used.\nThe 2nd approach uses binary search if the possible target \n`int x[5]={arr[0], arr[n/4], arr[n/2]... | 13 | 3 | ['Array', 'Binary Search', 'C', 'Sliding Window', 'C++', 'Python3'] | 3 |
element-appearing-more-than-25-in-sorted-array | Four lines to solve the problem | four-lines-to-solve-the-problem-by-dandr-tct8 | \nclass Solution {\n public int findSpecialInteger(int[] arr) {\n int limit=arr.length/4;\n for(int i=0;i<arr.length;i++){\n if(arr[ | dandrane | NORMAL | 2021-02-27T03:40:43.367015+00:00 | 2021-02-27T03:40:43.367047+00:00 | 657 | false | ```\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n int limit=arr.length/4;\n for(int i=0;i<arr.length;i++){\n if(arr[i]==arr[i+limit])\n return arr[i];\n }\n return -1;\n }\n}\n``` | 11 | 0 | ['Java'] | 3 |
element-appearing-more-than-25-in-sorted-array | No need for binary search - beats 100% | no-need-for-binary-search-beats-100-by-q-ktk9 | Since the array is sorted, we just need to check if arr[i] == arr[i + arr.length / 4]\n\n\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n | qiong7 | NORMAL | 2020-01-12T16:37:24.307945+00:00 | 2020-01-12T16:37:24.307978+00:00 | 1,379 | false | Since the array is sorted, we just need to check if arr[i] == arr[i + arr.length / 4]\n\n```\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n for (int i = 0; i < arr.length * 0.75; i++) {\n if (arr[i] == arr[i + arr.length / 4]) {\n return arr[i];\n }\n ... | 11 | 4 | [] | 3 |
element-appearing-more-than-25-in-sorted-array | Beats 97% very Easy | beats-97-very-easy-by-saim75-nc4a | 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 | saim75 | NORMAL | 2023-12-11T03:02:07.468746+00:00 | 2023-12-11T03:02:07.468781+00:00 | 981 | 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 | ['Python3'] | 4 |
element-appearing-more-than-25-in-sorted-array | [Java] Linear Scan | java-linear-scan-by-manrajsingh007-kfz1 | ```\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n int n = arr.length;\n int count = 1;\n int e = arr[0];\n for | manrajsingh007 | NORMAL | 2019-12-14T16:02:45.499795+00:00 | 2019-12-15T15:40:36.524124+00:00 | 1,025 | false | ```\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n int n = arr.length;\n int count = 1;\n int e = arr[0];\n for(int i = 1; i < n; i++){\n if(arr[i] == e) count++;\n else {\n e = arr[i];\n count = 1;\n }\n ... | 9 | 3 | [] | 1 |
element-appearing-more-than-25-in-sorted-array | Best Solution using Binary Search Approach with Proper Explanation and Beats 100% | best-solution-using-binary-search-approa-ho4q | Intuition\n Describe your first thoughts on how to solve this problem. \nArray is sorted so we think about binary search.\n\n# Approach\n Describe your approach | missionMicrosoft_7692 | NORMAL | 2023-12-11T04:47:02.589925+00:00 | 2023-12-11T04:48:25.874478+00:00 | 859 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nArray is sorted so we think about binary search.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe have to find element which apper more than n/4 times. So our possible answer is at \n\n[1-25]% or [25-50]% or [50-... | 8 | 1 | ['Array', 'Binary Search', 'Sorting', 'Counting', 'C++'] | 0 |
element-appearing-more-than-25-in-sorted-array | ✅EASY C++ SOLUTION IN 0(N)☑️ | easy-c-solution-in-0n-by-2005115-554o | PLEASE UPVOTE MY SOLUTION IF YOU LIKE IT\n# CONNECT WITH ME\n### https://www.linkedin.com/in/pratay-nandy-9ba57b229/\n#### https://www.instagram.com/pratay_nand | 2005115 | NORMAL | 2023-12-11T03:28:32.528993+00:00 | 2023-12-11T03:28:32.529018+00:00 | 943 | false | # **PLEASE UPVOTE MY SOLUTION IF YOU LIKE IT**\n# **CONNECT WITH ME**\n### **[https://www.linkedin.com/in/pratay-nandy-9ba57b229/]()**\n#### **[https://www.instagram.com/pratay_nandy/]()**\n\n# Approach\nThe given C++ code defines a function `findSpecialInteger` that aims to find and return an integer that appears more... | 8 | 0 | ['Array', 'Sliding Window', 'C++'] | 0 |
element-appearing-more-than-25-in-sorted-array | JAVA || HASHMAP || WELL EXPLAINED || 4 LINE CODE | java-hashmap-well-explained-4-line-code-v5jvl | Intuition\nFind the occurrence of an element and return the maximum occured element, For this I use HashMap.Since HashMap is an OPTIMIZED DATASTRUCTURE. \n\n\np | sharforaz_rahman | NORMAL | 2023-01-06T10:07:46.427733+00:00 | 2023-01-06T10:07:46.427776+00:00 | 916 | false | # Intuition\nFind the occurrence of an element and return the **maximum occured** element, For this I use HashMap.Since HashMap is an OPTIMIZED DATASTRUCTURE. \n\n\nplease upvote this if you like it.\n# Code\n```\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n HashMap<Integer,Integer> map = n... | 7 | 0 | ['Java'] | 2 |
element-appearing-more-than-25-in-sorted-array | Java 8 liner O(log N) (Only check 25% and 50%) | java-8-liner-olog-n-only-check-25-and-50-f34z | Here I\'m only checking the elements at 25% and 50% by binary search. if it is not in it, return element at 75%.\n\n\npublic int findSpecialInteger(int[] arr) { | vikrant_pc | NORMAL | 2020-12-19T07:55:49.878609+00:00 | 2021-08-29T00:51:21.083245+00:00 | 482 | false | Here I\'m only checking the elements at 25% and 50% by binary search. if it is not in it, return element at 75%.\n\n```\npublic int findSpecialInteger(int[] arr) {\n\tfor(int i=0;i<2;i++) { // Only check element at 25% and 50%\n\t\tint num = arr[arr.length*(i+1)/4], start = 0, end = arr.length*(i+1)/4;\n\t\twh... | 7 | 0 | ['Binary Tree'] | 0 |
element-appearing-more-than-25-in-sorted-array | Python 100%, O(logn), check 3 numbers (with explanations) | python-100-ologn-check-3-numbers-with-ex-gfo6 | The idea is simple: if the number occurs more than 25% times in the arr then it\'s at either one of indices: n / 4, n / 2, n / 4 * 3.\nFor ex. in an array of si | ihor_codes | NORMAL | 2020-10-23T06:50:48.003625+00:00 | 2020-10-23T06:50:48.003659+00:00 | 924 | false | The idea is simple: if the number occurs more than 25% times in the arr then it\'s at either one of indices: n / 4, n / 2, n / 4 * 3.\nFor ex. in an array of size 100, we\'d check indices 25, 50, 75.\nThen simply run a binary search to find the left and right boundary of the number.\n\nTime: O(6 * logn) = O(logn)\nSpac... | 7 | 1 | ['Binary Search', 'Python'] | 3 |
element-appearing-more-than-25-in-sorted-array | 【Video】Give me 5 minutes - 2 solutions - How we think about a solution | video-give-me-5-minutes-2-solutions-how-p5k8o | Intuition\nCalculate quarter length of input array.\n\n---\n\n# Solution Video\n\nhttps://youtu.be/bTm-6y7Ob0A\n\n\u25A0 Timeline of the video\n\n0:07 Explain a | niits | NORMAL | 2024-04-23T16:25:04.855448+00:00 | 2024-04-23T16:25:04.855472+00:00 | 998 | false | # Intuition\nCalculate quarter length of input array.\n\n---\n\n# Solution Video\n\nhttps://youtu.be/bTm-6y7Ob0A\n\n\u25A0 Timeline of the video\n\n`0:07` Explain algorithm of Solution 1\n`2:46` Coding of solution 1\n`3:49` Time Complexity and Space Complexity of solution 1\n`4:02` Step by step algorithm of solution 1\... | 6 | 0 | ['C++', 'Java', 'Python3', 'JavaScript'] | 0 |
element-appearing-more-than-25-in-sorted-array | 🔥Simple Optimize solution Detail Explanation🔥|2-line Solution|🔥Daily Challenges 🔥 | simple-optimize-solution-detail-explanat-znba | Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n\n# Code | Shree_Govind_Jee | NORMAL | 2023-12-11T00:39:42.543481+00:00 | 2023-12-11T00:40:39.723787+00:00 | 1,127 | false | # Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```Java []\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n/* \n HashMap<Integer, Integer> map ... | 6 | 0 | ['Array', 'C', 'C++', 'Java'] | 2 |
element-appearing-more-than-25-in-sorted-array | python log(N) sol | python-logn-sol-by-yefee-zq9v | \nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n \n \n for i in range(4):\n target = arr[len(arr)// | yefee | NORMAL | 2020-07-12T08:40:14.360716+00:00 | 2020-07-12T08:40:14.360762+00:00 | 476 | false | ```\nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n \n \n for i in range(4):\n target = arr[len(arr)//4 *i] # find the 0, 25, 50, 75%\n \n\t\t\t# left most val == target\n left = 0\n right = len(arr) - 1\n while lef... | 6 | 0 | [] | 2 |
element-appearing-more-than-25-in-sorted-array | simple Java solution 100% mm and 100% runtime | simple-java-solution-100-mm-and-100-runt-7i2r | \nclass Solution {\n public int findSpecialInteger(int[] arr) {\n int quater = arr.length / 4;\n int count = 1;\n \n if(arr.lengt | saketshetty | NORMAL | 2020-02-10T13:12:38.109820+00:00 | 2020-02-10T13:12:38.109859+00:00 | 402 | false | ```\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n int quater = arr.length / 4;\n int count = 1;\n \n if(arr.length == 1 ) return arr[0];\n \n for(int i=0; i<arr.length-1; i++){\n if(arr[i] == arr[i+1]){\n count++;\n ... | 6 | 1 | ['Java'] | 1 |
element-appearing-more-than-25-in-sorted-array | ✅ C++ Solution 🔥|| Straight Forward Solution 🔥 | c-solution-straight-forward-solution-by-j13yt | Intuition\n Describe your first thoughts on how to solve this problem. \nwe can use map to store frquency of each element.\n\n# Approach\n Describe your approac | BruteForce_03 | NORMAL | 2023-12-11T09:54:56.225543+00:00 | 2023-12-11T13:05:04.124983+00:00 | 78 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nwe can use `map` to store `frquency` of each element.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initialize Variables:\n - Initialize a `map` to `store` the `frequency` of each element.\n - Calculate ... | 5 | 0 | ['Ordered Map', 'Python', 'C++', 'JavaScript'] | 0 |
element-appearing-more-than-25-in-sorted-array | 🔥|| BEGINNER FRIENDLY || EXPLAINED IN HINDI || HASHMAP ||🔥 | beginner-friendly-explained-in-hindi-has-zxjp | Intuition\n Describe your first thoughts on how to solve this problem. \n\n1)Threshold Calculation (y):\ny ko calculate karte hain, jo array size ka 25% darshat | Sautramani | NORMAL | 2023-12-11T04:39:19.493725+00:00 | 2023-12-11T04:39:19.493745+00:00 | 740 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n1)Threshold Calculation (y):\ny ko calculate karte hain, jo array size ka 25% darshata hai.\n\n2)Frequency Map Creation:\nHar unique integer ki frequency ko store karne ke liye ek map (mp) banate hain.\n\n3)Populate Frequency Map:\nArra... | 5 | 0 | ['Array', 'Hash Table', 'Hash Function', 'Python', 'C++', 'Java'] | 2 |
element-appearing-more-than-25-in-sorted-array | Python easy to understand solution | python-easy-to-understand-solution-by-sh-cjoj | \nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n per = len(arr)//4\n for i in arr:\n occ = arr.count(i)\n | Shivam_Raj_Sharma | NORMAL | 2022-05-20T08:09:48.080401+00:00 | 2022-05-20T08:09:48.080430+00:00 | 707 | false | ```\nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n per = len(arr)//4\n for i in arr:\n occ = arr.count(i)\n if occ > per:\n return i\n``` | 5 | 0 | ['Array', 'Python', 'Python3'] | 0 |
element-appearing-more-than-25-in-sorted-array | JavaScript - Boyer-Moore Voting Algorithm | javascript-boyer-moore-voting-algorithm-otc09 | Hint from: https://leetcode.com/problems/majority-element/solution/\nApproach 6: Boyer-Moore Voting Algorithm\n\n Time: O(n)\n Space: O(1)\n\n> Sorting doesn\'t | shengdade | NORMAL | 2020-02-27T02:51:10.227431+00:00 | 2020-02-27T02:53:22.021730+00:00 | 399 | false | Hint from: https://leetcode.com/problems/majority-element/solution/\nApproach 6: Boyer-Moore Voting Algorithm\n\n* Time: O(n)\n* Space: O(1)\n\n> Sorting doesn\'t matter\n\n```javascript\n/**\n * @param {number[]} arr\n * @return {number}\n */\nvar findSpecialInteger = function(arr) {\n let candidate;\n let counter =... | 5 | 0 | ['JavaScript'] | 4 |
element-appearing-more-than-25-in-sorted-array | ✅☑[C++/Java/Python/JavaScript] || 2 Approaches || EXPLAINED🔥 | cjavapythonjavascript-2-approaches-expla-jmiy | PLEASE UPVOTE IF IT HELPED\n\n---\n\n\n# Approaches\n(Also explained in the code)\n\n#### Approach 1(With Hash Maps)\n1. HashMap (unordered_map):\n\n - Creat | MarkSPhilip31 | NORMAL | 2023-12-11T07:57:59.618829+00:00 | 2023-12-11T07:57:59.618864+00:00 | 249 | false | # PLEASE UPVOTE IF IT HELPED\n\n---\n\n\n# Approaches\n**(Also explained in the code)**\n\n#### ***Approach 1(With Hash Maps)***\n1. **HashMap (unordered_map):**\n\n - Create an unordered map (`counts`) to store the count of each element in the input array.\n - Iterate through the input array (`arr`) and count th... | 4 | 0 | ['Array', 'C', 'C++', 'Java', 'Python3', 'JavaScript'] | 1 |
element-appearing-more-than-25-in-sorted-array | Rust 1ms 🔥 2.43 Mb ☄️ One Liner Solution 🦀 | rust-1ms-243-mb-one-liner-solution-by-ro-b09p | Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co | rony0000013 | NORMAL | 2023-12-11T04:34:13.453993+00:00 | 2023-12-11T04:34:13.454024+00:00 | 109 | false | # Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nimpl Solution {\n pub fn find_special_integer(arr: Vec<i32>) -> i32 {\n [arr[arr.len()/4], arr[arr.len()/2], ... | 4 | 0 | ['Rust'] | 1 |
element-appearing-more-than-25-in-sorted-array | Simple approach without use of hashmap and extra libraries! | simple-approach-without-use-of-hashmap-a-a09r | Intuition\n Describe your first thoughts on how to solve this problem. \nSince the array elements are sorted whenever in the loop ith element equals i+len(arr)/ | yashaswisingh47 | NORMAL | 2023-12-11T04:28:56.866217+00:00 | 2023-12-11T04:28:56.866240+00:00 | 232 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSince the array elements are sorted whenever in the loop ith element equals i+len(arr)//4 th element. We will return the element.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!... | 4 | 0 | ['Python3'] | 0 |
element-appearing-more-than-25-in-sorted-array | HAPPY DECEMBER ☃️|| 2 APPROACHES ✅ GOOD EXPLANATION😊|| BEGINEER FRIENDLY 👌 | happy-december-2-approaches-good-explana-xefi | Intuition & Approaches :- \nHope everyone is doing great.. its going easy december right guys.. i m not posting answer in between as there are thosusand answers | DEvilBackInGame | NORMAL | 2023-12-11T01:37:17.066259+00:00 | 2023-12-11T01:56:12.682153+00:00 | 721 | false | # Intuition & Approaches :- \nHope everyone is doing great.. its going easy december right guys.. i m not posting answer in between as there are thosusand answers and for easy question with same approaches.. so i looked into other solutions & they are also good and well explained. if u want me to post all solution with... | 4 | 0 | ['Array', 'Ordered Map', 'C++'] | 3 |
element-appearing-more-than-25-in-sorted-array | simple c++ solution | simple-c-solution-by-prithviraj26-l1qs | 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 | prithviraj26 | NORMAL | 2023-02-06T14:18:18.456533+00:00 | 2023-02-06T14:18:18.456573+00:00 | 591 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\no(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n... | 4 | 0 | ['Array', 'Hash Table', 'C++'] | 1 |
element-appearing-more-than-25-in-sorted-array | Easy Python | easy-python-by-tusharkhanna575-yl4j | \nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n check=len(arr)//4\n c=dict((i,arr.count(i)) for i in arr)\n f | tusharkhanna575 | NORMAL | 2022-05-20T08:07:00.686655+00:00 | 2022-05-20T08:09:58.073066+00:00 | 838 | false | ```\nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n check=len(arr)//4\n c=dict((i,arr.count(i)) for i in arr)\n for k,v in c.items():\n if(c[k]>check):\n return k\n \n```\n**One more method**\n```\nclass Solution:\n def findSpecialInt... | 4 | 0 | ['Python', 'Python3'] | 1 |
element-appearing-more-than-25-in-sorted-array | 📌Fastest Java☕ Solution 0ms💯 | fastest-java-solution-0ms-by-saurabh_173-mbap | ```\nclass Solution {\n public int findSpecialInteger(int[] arr) \n {\n var x = arr.length/4;\n for(var i=0;i<arr.length;i++)\n i | saurabh_173 | NORMAL | 2022-05-01T15:10:50.267992+00:00 | 2022-05-01T15:10:50.268034+00:00 | 179 | false | ```\nclass Solution {\n public int findSpecialInteger(int[] arr) \n {\n var x = arr.length/4;\n for(var i=0;i<arr.length;i++)\n if(arr[i]==arr[i+x])\n return arr[i];\n return -1;\n }\n} | 4 | 0 | ['Array', 'Java'] | 2 |
element-appearing-more-than-25-in-sorted-array | Java Simple Sliding window | java-simple-sliding-window-by-hobiter-o9fq | \n public int findSpecialInteger(int[] arr) {\n int n = arr.length, l = 0, r = n / 4;\n while (r < n) if (arr[r++] == arr[l++]) return arr[--l] | hobiter | NORMAL | 2020-06-15T18:42:17.851665+00:00 | 2020-06-15T18:42:17.851715+00:00 | 154 | false | ```\n public int findSpecialInteger(int[] arr) {\n int n = arr.length, l = 0, r = n / 4;\n while (r < n) if (arr[r++] == arr[l++]) return arr[--l];\n return -1;\n }\n``` | 4 | 1 | [] | 0 |
element-appearing-more-than-25-in-sorted-array | Constant O(1) time, O(1) space, NO binary search needed, 0ms 100%/100% | constant-o1-time-o1-space-no-binary-sear-1ljn | The idea is to "sampling" the input array to a new array with a length of 9. If the input array has length of 9 or less, we just find the most common element (m | truongsinh | NORMAL | 2020-02-27T15:45:05.408632+00:00 | 2020-02-28T10:22:04.684140+00:00 | 727 | false | The idea is to "sampling" the input array to a new array with a length of 9. If the input array has length of 9 or less, we just find the most common element (mode). Otherwise, no matter how large the input is, we just need exactly 9 points to compare, 2 of which are first and last item of the array, the remaining 7 in... | 4 | 0 | ['Python', 'C++', 'Java'] | 2 |
element-appearing-more-than-25-in-sorted-array | very easy without binary search.... | very-easy-without-binary-search-by-tpx_c-q68l | class Solution {\npublic:\n int findSpecialInteger(vector& arr) {\n \n int res;\n \n for(int i=0;i<arr.size();i++)\n {\n | tpx_coder-28 | NORMAL | 2020-01-07T13:35:18.911165+00:00 | 2020-01-07T13:35:18.911197+00:00 | 450 | false | class Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n \n int res;\n \n for(int i=0;i<arr.size();i++)\n {\n if(arr[i]==arr[i+arr.size()/4])\n {\n return arr[i];\n break;\n }\n }\n \n ... | 4 | 1 | [] | 1 |
element-appearing-more-than-25-in-sorted-array | Python solution 💥 🔥 | python-solution-by-noy25-nbkd | Intuition\n Describe your first thoughts on how to solve this problem. \nThis Python code aims to find a special integer in the given array arr. A special integ | noy25 | NORMAL | 2024-01-02T19:44:55.446627+00:00 | 2024-01-02T19:44:55.446652+00:00 | 11 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis Python code aims to find a special integer in the given array arr. A special integer is defined as an integer that appears more than 25% of the array\'s length. The code iterates through the array, comparing each element with the ele... | 3 | 0 | ['Array', 'Python'] | 0 |
element-appearing-more-than-25-in-sorted-array | Simple solution for Element Appearing More Than 25% In Sorted Array | simple-solution-for-element-appearing-mo-cjip | Approach\nOne more simple solution without using Hash Map or Binary Search.\n\n# Code\n\n/**\n * @param {number[]} arr\n * @return {number}\n */\nvar findSpecia | klim9d61 | NORMAL | 2023-12-11T19:12:02.203691+00:00 | 2023-12-11T19:12:02.203723+00:00 | 31 | false | # Approach\nOne more simple solution without using Hash Map or Binary Search.\n\n# Code\n```\n/**\n * @param {number[]} arr\n * @return {number}\n */\nvar findSpecialInteger = function(arr) {\n const oneQuarter = arr.length / 4;\n let count = 0;\n\n if(arr.length === 1) {\n return arr[0];\n }\n\n ... | 3 | 0 | ['TypeScript', 'JavaScript'] | 0 |
element-appearing-more-than-25-in-sorted-array | Beats 100% of users with C++ ( Using HashMap ) Time Complexity { O ( logN ) } | beats-100-of-users-with-c-using-hashmap-4dvx2 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n\n\n\n\n\n\nif you like the approach please upvote it\n\n\n\n\n\n\nif you like the ap | abhirajpratapsingh | NORMAL | 2023-12-11T10:07:51.077506+00:00 | 2023-12-11T10:07:51.077547+00:00 | 7 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n\n\n\n\n\n\nif you like the approach please upvote it\n\n\n\n\n\n\nif you like the approach please upvote it\n\n# Approach... | 3 | 0 | ['Array', 'Ordered Map', 'Counting', 'C++'] | 0 |
element-appearing-more-than-25-in-sorted-array | Simple solution in TypeScript using Map(). | simple-solution-in-typescript-using-map-35ws9 | Approach\nUsing a map variable to store the count of each element. If the count of a particular element is more than 25% of the sorted array, that is it!\n\n# C | vineethvg | NORMAL | 2023-12-11T09:57:10.989387+00:00 | 2023-12-11T09:57:10.989410+00:00 | 58 | false | # Approach\nUsing a map variable to store the count of each element. If the count of a particular element is more than 25% of the sorted array, that is it!\n\n# Complexity\n- Time complexity: $$O(N)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(N)$$\n<!-- Add your space complexity ... | 3 | 0 | ['TypeScript'] | 0 |
element-appearing-more-than-25-in-sorted-array | Simple | Beat 100% | ✅ | simple-beat-100-by-shadab_ahmad_khan-or0b | Intuition\n\n# Code\n\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n if(arr.length<=2) return arr[0];\n int appearingCount= a | Shadab_Ahmad_Khan | NORMAL | 2023-12-11T07:02:23.514642+00:00 | 2023-12-11T07:03:30.414060+00:00 | 222 | false | # Intuition\n\n# Code\n```\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n if(arr.length<=2) return arr[0];\n int appearingCount= arr.length/4;\n int count=... | 3 | 0 | ['Array', 'Java'] | 0 |
element-appearing-more-than-25-in-sorted-array | Easy Approach||Beginner friendly||Maps||beats 90%users | easy-approachbeginner-friendlymapsbeats-zzlij | 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 | Hitheash | NORMAL | 2023-12-11T02:38:42.224695+00:00 | 2023-12-11T02:38:42.224724+00:00 | 669 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 3 | 0 | ['C++'] | 0 |
element-appearing-more-than-25-in-sorted-array | ⭐One-Liner Hack in 🐍|| Two Approaches ||😐Beats 75.32%😐⭐ | one-liner-hack-in-two-approaches-beats-7-bzdx | \n# Code\npy\nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n return next(i for i in arr if arr.count(i) / len(arr) > 0.25)\n | ShreejitCheela | NORMAL | 2023-12-11T00:09:37.960015+00:00 | 2023-12-11T00:09:37.960032+00:00 | 690 | false | \n# Code\n```py\nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n return next(i for i in arr if arr.count(i) / len(arr) > 0.25)\n```\n ---\n\n\n# Code\n```py\nclass Solution... | 3 | 0 | ['Python3'] | 0 |
element-appearing-more-than-25-in-sorted-array | JavaScript Binary Search O(log n) | javascript-binary-search-olog-n-by-ekteg-myfx | This is total overkill for this problem, but here goes.\n\nWe can split arr into 4 parts\n\n[a, a, a, a | b, b, b, b | c, c, c, c | d, d, d, d]\n\nIf an element | ektegjetost | NORMAL | 2022-05-14T16:59:35.822041+00:00 | 2022-05-14T17:01:35.047973+00:00 | 151 | false | This is total overkill for this problem, but here goes.\n\nWe can split arr into 4 parts\n```\n[a, a, a, a | b, b, b, b | c, c, c, c | d, d, d, d]\n```\nIf an element appears more than more than a quarter of the time, there\'s no way it can hide inside of one of these parts, so we\'re guaranteed to find it if we check ... | 3 | 0 | ['Binary Tree', 'JavaScript'] | 0 |
element-appearing-more-than-25-in-sorted-array | Sliding Window Technique , intuitive Go SOln | sliding-window-technique-intuitive-go-so-utlm | \nfunc findSpecialInteger(arr []int) int {\n\tn := len(arr)\n\tt := n / 4\n\n\tfor i := 0; i < n-t; i++ {\n\t\tif arr[i] == arr[i+t] {\n\t\t\treturn arr[i]\n\t\ | pradeep288 | NORMAL | 2021-10-26T07:30:16.474856+00:00 | 2021-10-26T07:30:16.474906+00:00 | 101 | false | ```\nfunc findSpecialInteger(arr []int) int {\n\tn := len(arr)\n\tt := n / 4\n\n\tfor i := 0; i < n-t; i++ {\n\t\tif arr[i] == arr[i+t] {\n\t\t\treturn arr[i]\n\t\t}\n\t}\n\n\treturn -1\n}\n``` | 3 | 0 | ['Go'] | 0 |
element-appearing-more-than-25-in-sorted-array | JAVA 100% faster (On/O1) | java-100-faster-ono1-by-movsar-1o9g | \nclass Solution {\n public int findSpecialInteger(int[] arr) {\n // 25% is 1/4 of numbers in arr\n\t// if length is 9, 25% is 9 / 4 = 2,5\n\t// round up to | movsar | NORMAL | 2021-09-18T21:49:46.201310+00:00 | 2021-09-18T21:49:46.201350+00:00 | 289 | false | ```\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n // 25% is 1/4 of numbers in arr\n\t// if length is 9, 25% is 9 / 4 = 2,5\n\t// round up to next int\n int q = Math.round(arr.length / 4) + 1;\n int res = 0, temp = 1;\n\n if (arr.length == 1) return arr[res];\n\n for (int i = 1; i < ar... | 3 | 0 | ['Java'] | 0 |
element-appearing-more-than-25-in-sorted-array | Simple Binary Search | C++ | log n Solution | simple-binary-search-c-log-n-solution-by-sxlz | \tint singleNonDuplicate(vector& nums) {\n int n=nums.size();\n int lo=0,hi=n-1;int mid;\n while(lo<hi)\n {\n mid=lo+(hi- | nikhilsharmaiiita | NORMAL | 2021-05-05T17:37:41.105722+00:00 | 2021-05-05T17:39:15.168943+00:00 | 141 | false | \tint singleNonDuplicate(vector<int>& nums) {\n int n=nums.size();\n int lo=0,hi=n-1;int mid;\n while(lo<hi)\n {\n mid=lo+(hi-lo+1)/2;\n //here we test if numbet of element left side of mid is even or not\n if((mid-lo)%2==0)\n {\n //... | 3 | 1 | [] | 0 |
element-appearing-more-than-25-in-sorted-array | Python3 simple solution using four approaches | python3-simple-solution-using-four-appro-td7a | \nfrom collections import Counter\nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n n = len(arr)\n x = Counter(arr)\n | EklavyaJoshi | NORMAL | 2021-03-11T05:20:23.736992+00:00 | 2021-03-11T05:20:23.737026+00:00 | 169 | false | ```\nfrom collections import Counter\nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n n = len(arr)\n x = Counter(arr)\n for i in x:\n if x[i] > n/4:\n return i\n```\n\n\n\n```\nclass Solution:\n def findSpecialInteger(self, arr: List[int]) ->... | 3 | 1 | ['Python3'] | 0 |
element-appearing-more-than-25-in-sorted-array | [C++] 4 Solutions | c-4-solutions-by-zxspring21-ubxv | C++:\n\n(1) Find the element at position n/4, n/2, n*3/4 and check lastOccurence-firstOccurence+1 > n/4\n\n\nint findSpecialInteger(vector<int>& arr) {\n\tint n | zxspring21 | NORMAL | 2020-09-03T01:27:49.733884+00:00 | 2020-09-03T01:29:13.493749+00:00 | 462 | false | **C++:**\n\n**(1) Find the element at position n/4, n/2, n*3/4 and check lastOccurence-firstOccurence+1 > n/4**\n\n```\nint findSpecialInteger(vector<int>& arr) {\n\tint n = arr.size();\n\tfor(auto &i:{n/4,n/2,n*3/4}){\n\t auto p = equal_range(arr.begin(),arr.end(),arr[i]); //return [first,last) with values equivalent... | 3 | 1 | ['C'] | 0 |
element-appearing-more-than-25-in-sorted-array | beats 100% java solution | beats-100-java-solution-by-yyyfor-gyez | \nclass Solution {\n public int findSpecialInteger(int[] arr) {\n for(int i = 0 ; i < arr.length; i++) {\n if(arr[i] == arr[i + arr.length/ | yyyfor | NORMAL | 2020-05-13T07:50:02.348884+00:00 | 2020-05-13T07:50:02.348935+00:00 | 155 | false | ```\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n for(int i = 0 ; i < arr.length; i++) {\n if(arr[i] == arr[i + arr.length/4]) {\n return arr[i];\n }\n }\n \n return 0;\n }\n}\n``` | 3 | 1 | [] | 1 |
element-appearing-more-than-25-in-sorted-array | javascript, sliding window, 90%/100%, w/ comments | javascript-sliding-window-90100-w-commen-0u16 | \nfunction findSpecialInteger(arr) {\n // get \'window\' size which is just 25% of array to int\n const w = Math.ceil(arr.length * 0.25);\n // just ite | carti | NORMAL | 2020-04-20T23:30:42.013996+00:00 | 2020-04-20T23:30:42.014046+00:00 | 205 | false | ```\nfunction findSpecialInteger(arr) {\n // get \'window\' size which is just 25% of array to int\n const w = Math.ceil(arr.length * 0.25);\n // just iterate thru array until window reaches end\n for (let i = 0; i + w < arr.length; i++) {\n // if number at beginning and end of window are same,\n ... | 3 | 1 | ['Sliding Window', 'JavaScript'] | 2 |
element-appearing-more-than-25-in-sorted-array | Python, one liner using collections.Counter | python-one-liner-using-collectionscounte-7pje | \nfrom collections import Counter\nclass Solution:\n def findSpecialInteger(self, arr):\n return Counter(arr).most_common(1)[0][0]\n | bison_a_besoncon | NORMAL | 2019-12-14T16:16:58.513937+00:00 | 2019-12-14T16:16:58.513969+00:00 | 489 | false | ```\nfrom collections import Counter\nclass Solution:\n def findSpecialInteger(self, arr):\n return Counter(arr).most_common(1)[0][0]\n``` | 3 | 2 | [] | 4 |
element-appearing-more-than-25-in-sorted-array | Time - log(n) & Constant Space Solution | time-logn-constant-space-solution-by-pop-ssfv | Just check 3 elements\nat 25th, 50th & 75 th\n\n```\n\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n int e = arr.length < 4 ? 1 : ar | popeye_the_sailort | NORMAL | 2019-12-14T16:01:56.460033+00:00 | 2019-12-14T16:04:38.125732+00:00 | 381 | false | Just check 3 elements\nat 25th, 50th & 75 th\n\n```\n\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n int e = arr.length < 4 ? 1 : arr.length/4;\n int pos = e;\n for(int i=0; i<3; pos+=e) {\n int val = arr[pos-1];\n if(findCount(arr, val) > arr.length/4) {\... | 3 | 0 | [] | 0 |
element-appearing-more-than-25-in-sorted-array | Very Simple Solution in Java, CPP and Python, easy to visualize - O(n) time & O(1) space. | very-simple-solution-in-java-cpp-and-pyt-ga68 | null | v-athithyaramaa | NORMAL | 2024-12-10T11:57:13.394936+00:00 | 2024-12-10T11:57:13.394936+00:00 | 78 | false | # Intuition\nAccording to the problem, you\'re given a list of numbers that\u2019s **already sorted** in order. We have to find the number that shows up **more than 25% of the time.** In other words, you\'re looking for the number that is repeated more than any other number \u2014 at least one in every four numbers in ... | 2 | 0 | ['Array', 'C++', 'Java', 'Python3'] | 0 |
element-appearing-more-than-25-in-sorted-array | Best and Easy Approach...... || Beginners friendly...🔥🔥🔥 | best-and-easy-approach-beginners-friendl-3mjs | Approach\n Describe your approach to solving the problem. \n1. Initialize an empty dictionary \'arr2\' to store the count of occurrences for each unique element | Awanish_singh001 | NORMAL | 2023-12-13T20:03:45.492843+00:00 | 2023-12-13T20:03:45.492869+00:00 | 422 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initialize an empty dictionary \'arr2\' to store the count of occurrences for each unique element in the input array.\n2. Iterate through each element i in the input array arr.\n3. If i is already a key in \'arr2\', increment its count.\n4. If i is... | 2 | 0 | ['Array', 'Python', 'Python3'] | 2 |
element-appearing-more-than-25-in-sorted-array | Solution in C++ | solution-in-c-by-adamblack-y9sz | One of the best solution for this problem!\n\n# Complexity\n- Time complexity: O(n)\n- \n# Code\n\nclass Solution {\npublic:\n int findSpecialInteger(vector< | AdamBlack | NORMAL | 2023-12-11T20:01:24.983877+00:00 | 2023-12-11T20:01:24.983907+00:00 | 17 | false | One of the best solution for this problem!\n\n# Complexity\n- Time complexity: O(n)\n- \n# Code\n```\nclass Solution {\npublic:\n int findSpecialInteger(vector<int>& arr) {\n int x = 0, mx = 0, res = 0;\n int l = arr.size(); // Use size() instead of length() for vectors\n if(l<=2){\n ... | 2 | 0 | ['C++'] | 0 |
element-appearing-more-than-25-in-sorted-array | Percentage of 25 with value n | percentage-of-25-with-value-n-by-nithinu-1xc4 | Approach\n Finding Percentage value with the length of the arraylist and \n find frequency of every element further return the value when\n it across t | nithinu2810 | NORMAL | 2023-12-11T18:21:55.820019+00:00 | 2023-12-11T18:21:55.820046+00:00 | 3 | false | # Approach\n Finding Percentage value with the length of the arraylist and \n find frequency of every element further return the value when\n it across the limit.\n\n# Complexity\n- Time complexity: 1ms\n\n- Space complexity: 44.42mb\n\n# Code\n```\nclass Solution {\n public int findSpecialInteger(int[] arr... | 2 | 0 | ['Array', 'Math', 'Java'] | 0 |
element-appearing-more-than-25-in-sorted-array | C# Code with o(N) complexity and o(1) space | c-code-with-on-complexity-and-o1-space-b-yv01 | 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 | sivapandu | NORMAL | 2023-12-11T16:06:51.906656+00:00 | 2023-12-11T16:06:51.906694+00:00 | 52 | 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#'] | 1 |
element-appearing-more-than-25-in-sorted-array | Simple JS Implementation | simple-js-implementation-by-itspravas-ior9 | Approach: Check the Element N/4 Ahead\n\n/**\n * @param {number[]} arr\n * @return {number}\n */\nvar findSpecialInteger = function (arr) {\n const n = arr.l | itspravas | NORMAL | 2023-12-11T16:05:49.028869+00:00 | 2023-12-11T16:05:49.028898+00:00 | 24 | false | # Approach: Check the Element N/4 Ahead\n```\n/**\n * @param {number[]} arr\n * @return {number}\n */\nvar findSpecialInteger = function (arr) {\n const n = arr.length, maxCnt = Math.floor(n / 4);\n for (let i = 0; i < n - maxCnt; i++) {\n if (arr[i] === arr[i + maxCnt]) return arr[i];\n }\n return -... | 2 | 0 | ['JavaScript'] | 0 |
element-appearing-more-than-25-in-sorted-array | Easy Binary Search Solution Explained!!🚀 | Java | easy-binary-search-solution-explained-ja-jmd1 | \n\n# Approach\n Describe your approach to solving the problem. \n- Use Binary search to find the last index of the occurence of element present at index i. \n- | rosh_01 | NORMAL | 2023-12-11T13:35:17.748628+00:00 | 2023-12-11T13:35:17.748678+00:00 | 146 | false | \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Use Binary search to find the last index of the occurence of element present at index i. \n- Then find the frequency/count of the element by using the formula:\n` last index - first index + 1`\nIn out case, first index will be i and last index w... | 2 | 0 | ['Binary Search', 'Java'] | 1 |
element-appearing-more-than-25-in-sorted-array | beats 100% || JAVA || Brute force --> Best Approach || clean code with explanation | beats-100-java-brute-force-best-approach-yhqh | Approach - 1 : Bruteforce Approach O(n^2)\n1. Iterate through the array and for each element, count its occurrences by traversing the array again.\n\n2. Keep tr | Nikhil_Pall | NORMAL | 2023-12-11T12:55:16.282510+00:00 | 2023-12-11T12:55:16.282539+00:00 | 43 | false | # Approach - 1 : Bruteforce Approach O(n^2)\n1. Iterate through the array and for each element, count its occurrences by traversing the array again.\n\n2. Keep track of the element with the highest count and return it as the answer.\n\n# Complexity\n- Time complexity: O(n^2)\n\n- Space complexity: O(1)\n\n# Code\n```\n... | 2 | 0 | ['Array', 'Java'] | 1 |
element-appearing-more-than-25-in-sorted-array | check the element n/4 steps back | Easy to understand | Java | C++ | check-the-element-n4-steps-back-easy-to-db876 | Intuition and Approach\nSince the array is in sorted oder. We can leverage this fact and check what was the number or say element n/4 steps back from current in | Fly_ing__Rhi_no | NORMAL | 2023-12-11T10:22:23.991146+00:00 | 2023-12-11T10:22:23.991200+00:00 | 585 | false | # Intuition and Approach\nSince the array is in sorted oder. We can leverage this fact and check what was the number or say element n/4 steps back from current index while traversing the array form left to right \n\n# Complexity\n- Time complexity:\nO(n), n is size of given arr\n\n- Space complexity:\nO(1)\n\n# Code\nC... | 2 | 0 | ['C++', 'Java'] | 1 |
element-appearing-more-than-25-in-sorted-array | Space Complexity O(1) | space-complexity-o1-by-pra__kash-yhe9 | 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 | pra__kash | NORMAL | 2023-12-11T09:01:38.091430+00:00 | 2023-12-11T09:01:38.091458+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $... | 2 | 0 | ['Array', 'C++'] | 0 |
element-appearing-more-than-25-in-sorted-array | Python | Easy | python-easy-by-khosiyat-gx3x | see the Successfully Accepted Submission\npython\nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n frequency_threshold = int( | Khosiyat | NORMAL | 2023-12-11T08:54:31.887374+00:00 | 2023-12-11T08:54:31.887402+00:00 | 33 | false | [see the Successfully Accepted Submission](https://leetcode.com/submissions/detail/1117078947/)\n```python\nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n frequency_threshold = int(len(arr) * 0.25)\n counter, index = 0, 0\n\n for i in range(len(arr)):\n if i... | 2 | 0 | ['Python'] | 0 |
element-appearing-more-than-25-in-sorted-array | ✅ Very simple recursive solution, follow best practices of Scala | very-simple-recursive-solution-follow-be-lmcr | Approach\nRecursive solution:\n\n+ No loop\n+ No vars declaration\n+ Functional style\n\n\n# Complexity\nTime complexity: O(n)\n\nSpace complexity: O(1)\n\n# Co | user6828v | NORMAL | 2023-12-11T08:32:12.319912+00:00 | 2023-12-11T08:41:19.630605+00:00 | 44 | false | # Approach\n**Recursive solution:**\n\n+ No loop\n+ No vars declaration\n+ Functional style\n\n\n# Complexity\n**Time complexity:** O(n)\n\n**Space complexity:** O(1)\n\n# Code\n```\nobject Solution {\n def findSpecialInteger(arr: Array[Int]): Int = {\n val dist = (arr.length * 0.25).toInt\n def findFrom(i: Int)... | 2 | 0 | ['Recursion', 'Scala'] | 0 |
element-appearing-more-than-25-in-sorted-array | JAVA solution explanation in HINDI | java-solution-explanation-in-hindi-by-th-oao8 | https://youtu.be/53yxKXB-tB8\n\nFor explanation watch the above video and do like, share and subscribe \u2764\uFE0F\n\n# Code\n\nclass Solution {\n public in | The_elite | NORMAL | 2023-12-11T07:27:03.430022+00:00 | 2023-12-11T07:27:03.430053+00:00 | 9 | false | https://youtu.be/53yxKXB-tB8\n\nFor explanation watch the above video and do like, share and subscribe \u2764\uFE0F\n\n# Code\n```\nclass Solution {\n public int findSpecialInteger(int[] arr) {\n \n Map<Integer, Integer> counts = new HashMap<>();\n for(int e : arr) {\n counts.put(e, c... | 2 | 0 | ['Java'] | 0 |
element-appearing-more-than-25-in-sorted-array | Simple Solution ✅ + 100% | simple-solution-100-by-probablylost-kg89 | Code\n\nclass Solution {\n func findSpecialInteger(_ arr: [Int]) -> Int {\n let quarter = arr.count / 4\n var candidate: Int?\n var coun | ProbablyLost | NORMAL | 2023-12-11T06:59:07.988917+00:00 | 2023-12-11T06:59:07.988936+00:00 | 16 | false | # Code\n```\nclass Solution {\n func findSpecialInteger(_ arr: [Int]) -> Int {\n let quarter = arr.count / 4\n var candidate: Int?\n var count = 0\n \n for (index, num) in arr.enumerated() {\n if num == candidate {\n count += 1\n } else {\n ... | 2 | 0 | ['Swift'] | 0 |
element-appearing-more-than-25-in-sorted-array | C++ | Simple Code | Beat 80% | c-simple-code-beat-80-by-ankita2905-d0s3 | 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 | Ankita2905 | NORMAL | 2023-12-11T06:50:17.888691+00:00 | 2023-12-11T06:50:17.888721+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 2 | 0 | ['C++'] | 0 |
element-appearing-more-than-25-in-sorted-array | 2 Approaches Using HashMap and Counter variable || Beats 100% ||JAVA||C++|| Jai Shree Ram🙏🙏 | 2-approaches-using-hashmap-and-counter-v-38bt | \n# Approach 1\n Describe your approach to solving the problem. \n - Using HashMap\n\n# Complexity\n- Time complexity: O(N)\n Add your time complexity here, e. | vermayugam_29 | NORMAL | 2023-12-11T06:25:05.774318+00:00 | 2023-12-11T06:25:05.774343+00:00 | 357 | false | \n# Approach 1\n<!-- Describe your approach to solving the problem. -->\n - Using HashMap\n\n# Complexity\n- Time complexity: $$O(N)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity: $$O(N)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```JAVA []\nclass Solution... | 2 | 0 | ['Array', 'Hash Table', 'Counting', 'C++', 'Java'] | 0 |
element-appearing-more-than-25-in-sorted-array | Solution using C++ | solution-using-c-by-truongtamthanh2004-ndfg | 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 | truongtamthanh2004 | NORMAL | 2023-12-11T06:07:01.126304+00:00 | 2023-12-11T06:07:01.126330+00:00 | 111 | 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<!-- 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++'] | 1 |
element-appearing-more-than-25-in-sorted-array | Easiest C++ Approach [Fastest] | Beats 100 % | easiest-c-approach-fastest-beats-100-by-5h00h | Intuition\nThe main approach of this code is to find and return an integer in the given array (arr) that occurs more than 25% of the array\'s length.\n\n# Appro | clickdawg | NORMAL | 2023-12-11T04:17:09.580751+00:00 | 2023-12-11T04:17:09.580779+00:00 | 115 | false | # Intuition\nThe main approach of this code is to find and return an integer in the given array (arr) that occurs more than 25% of the array\'s length.\n\n# Approach\n### Initialize Variables:\n- int n = arr.size() / 4;: Calculate a threshold value n representing 25% of the array length.\n### Create a Map (mp):\n- map<... | 2 | 0 | ['Array', 'Ordered Map', 'C++'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.