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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Solution in O(n) in C++ | solution-in-on-in-c-by-tk24-ifxr | IntuitionThe approach is similar to a sliding window, where you consider three consecutive nodes at a time: previous, current, and next. As you move through the | Kodertej | NORMAL | 2025-02-16T16:05:27.390803+00:00 | 2025-02-16T16:05:27.390803+00:00 | 19 | false | # Intuition
The approach is similar to a sliding window, where you consider three consecutive nodes at a time: previous, current, and next. As you move through the list, you slide this window step by step, checking if the current node is a critical point by comparing it with its neighbors.
# Approach
The approach slid... | 1 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Easy C++ Solution | | Beats 100% | easy-c-solution-beats-100-by-krishmalviy-qtf9 | Complexity
Time complexity: O(N)
Space complexity: O(N)
Code | Krish_004 | NORMAL | 2025-01-25T23:26:37.542075+00:00 | 2025-01-25T23:26:37.542075+00:00 | 13 | false | # Complexity
- Time complexity: $$O(N)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: $$O(N)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```cpp []
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : ... | 1 | 0 | ['Linked List', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 2 POINTER APPROACH, TC = O(N), SC = O(1) | 2-pointer-approach-tc-on-sc-o1-by-dkvmah-8296 | IntuitionApproachComplexity
Time complexity:
O(N)
Space complexity:
O(1)
Code | DkVMAH7YOG | NORMAL | 2025-01-10T13:05:31.978151+00:00 | 2025-01-10T13:05:31.978151+00:00 | 18 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
O(N)
- Space complexity:
O(1)
# Code
```cpp []
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* List... | 1 | 0 | ['Linked List', 'Two Pointers', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Two pointer Data store || 100% Beat | two-pointer-data-store-100-beat-by-ds_si-22vp | \n### Problem Statement\n\nGiven a singly linked list, a critical point is a node that satisfies one of the following conditions:\n1. It is a local maximum, mea | DS_Sijwali | NORMAL | 2024-12-01T11:37:18.852777+00:00 | 2024-12-01T11:37:18.852798+00:00 | 6 | false | \n### **Problem Statement**\n\nGiven a singly linked list, a **critical point** is a node that satisfies one of the following conditions:\n1. It is a **local maximum**, meaning its value is greater than the values of its adjacent nodes.\n2. It is a **local minimum**, meaning its value is less than the values of its adj... | 1 | 0 | ['Linked List', 'Two Pointers', 'Java'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Best C++ Code (beats 98%) | best-c-code-beats-98-by-souravsinghal200-h43y | 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 | souravsinghal2004 | NORMAL | 2024-09-11T07:16:21.979445+00:00 | 2024-09-11T07:16:21.979467+00:00 | 1 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 2058. Simple Traversal Solution with explanation | 2058-simple-traversal-solution-with-expl-mf2r | \n\'\'\'\n- At first, we need to find the Positions of Critical Points\n- Either we can store all those Critical Points Positions in some data structure and can | TrGanesh | NORMAL | 2024-07-14T18:00:21.772159+00:00 | 2024-07-14T18:00:21.772198+00:00 | 3 | false | ```\n\'\'\'\n- At first, we need to find the Positions of Critical Points\n- Either we can store all those Critical Points Positions in some data structure and can do some processing on it\n- Otherwise we can think about which Critical Points are Necessary/Needed for calculating the Minimum & Maximum Distance\n- Maximu... | 1 | 0 | ['Linked List', 'Python3'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Easy java Solution || Beats 100% | easy-java-solution-beats-100-by-akshay16-64n8 | \n\n# Code\n\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {}\n * ListN | akshay1610 | NORMAL | 2024-07-06T11:05:02.137360+00:00 | 2024-07-06T11:05:02.137389+00:00 | 6 | false | \n\n# Code\n```\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {}\n * ListNode(int val) { this.val = val; }\n * ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n */\nclass Solution {\n public int[... | 1 | 0 | ['Linked List', 'Java'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 🔗 Finding Distances Between Critical Points in a Linked List 🔗 | BEATS 100% ✅✅ | finding-distances-between-critical-point-bp4z | Intuition\n Describe your first thoughts on how to solve this problem. \nThe idea is to identify critical points in a linked list. A node is a critical point if | Mervis_Mascarenhas | NORMAL | 2024-07-06T08:59:06.060966+00:00 | 2024-07-06T08:59:06.060997+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe idea is to identify critical points in a linked list. A node is a critical point if its value is either a local minimum or a local maximum. We need to traverse the linked list to identify these critical points and then calculate the d... | 1 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | JAVA | | Time complexity: O(N) | | Space complexity: O(1) | java-time-complexity-on-space-complexity-n2zw | \n# Approach\n- Store the first maxima encountered\n- Store the last maxima encountered\n- Minimum distance will always be the distance between two subsequent m | demetra21104 | NORMAL | 2024-07-05T21:36:55.398266+00:00 | 2024-07-05T21:39:14.896756+00:00 | 2 | false | \n# Approach\n- Store the first maxima encountered\n- Store the last maxima encountered\n- Minimum distance will always be the distance between two subsequent maximas, so compute distance as you progress along the linked list\n- Maximum distance will always be = Last maxima encountered - First maxima encountered\n\n\n#... | 1 | 0 | ['Java'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Leetcode Daily #1 | leetcode-daily-1-by-dajonas-i2tt | 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 | dajonas | NORMAL | 2024-07-05T20:04:29.784969+00:00 | 2024-07-05T20:04:29.784997+00:00 | 14 | 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... | 1 | 0 | ['Python3'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | O(n) Solution | Single Pass | Basic Logic | O(1) Memory Complexity | on-solution-single-pass-basic-logic-o1-m-h1p9 | Intuition\nThe problem is very straight forward, we need to know the positions of minimums and maximums and have to find mininum distance and maximum difference | sauram228 | NORMAL | 2024-07-05T19:35:46.314407+00:00 | 2024-07-05T19:35:46.314437+00:00 | 10 | false | # Intuition\nThe problem is very straight forward, we need to know the positions of minimums and maximums and have to find mininum distance and maximum difference between all the pairs.\n\nNow, I will be using critical point to symbolize either minimum/maximnum\n\nMaximum distance is simple which is ```last critical po... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | ✅☑[C++/Java/Python/JavaScript] || Easy Implementation || EXPLAINED🔥 | cjavapythonjavascript-easy-implementatio-n4bn | PLEASE UPVOTE IF IT HELPED\n\n---\n\n\n# Approaches\n(Also explained in the code)\n\n1. Map Structure: Uses a map<pair<char, int>, int> to store the count of ch | MarkSPhilip31 | NORMAL | 2023-12-31T04:25:05.151185+00:00 | 2023-12-31T04:25:05.151209+00:00 | 3,799 | false | # PLEASE UPVOTE IF IT HELPED\n\n---\n\n\n# Approaches\n(Also explained in the code)\n\n1. **Map Structure:** Uses a `map<pair<char, int>, int>` to store the count of character sequences along with their lengths.\n1. **Iterating through String:** Iterates through the string to count the length of each character sequence... | 30 | 2 | ['String', 'Ordered Map', 'Python', 'C++', 'Java', 'Python3', 'JavaScript'] | 8 |
find-longest-special-substring-that-occurs-thrice-i | Python 3 || 7 lines, groupby and dict || T/S: 85% / 54% | python-3-7-lines-groupby-and-dict-ts-85-q6vdy | Here\'s the plan: \n1. We parse the the string into a list of strings of one character. (For example: \'aabeee\' --> [\'aa\', \'b\', \'eee\'])\n1. We increment | Spaulding_ | NORMAL | 2023-12-31T21:44:45.320313+00:00 | 2024-12-10T00:36:29.756731+00:00 | 516 | false | Here\'s the plan: \n1. We parse the the string into a list of strings of one character. (For example: `\'aabeee\' --> [\'aa\', \'b\', \'eee\']`)\n1. We increment a dict to track the beautiful strings; the trick here is to account for all substrings in a particular beautiful string, as there are also shorter beautiful ... | 16 | 0 | ['C++', 'Java', 'Python3'] | 4 |
find-longest-special-substring-that-occurs-thrice-i | ✅🔥Brute Force to Optimized ✅🔥 - Fully Explained | brute-force-to-optimized-fully-explained-1fmq | Problem \nYou are given a string s. Your task is to find the maximum length of a special substring in s that is occuring atleast 3 times. A special substring is | harsh_reality_ | NORMAL | 2023-12-31T04:19:43.490688+00:00 | 2023-12-31T04:19:43.490719+00:00 | 1,844 | false | # Problem \nYou are given a string ```s```. Your task is to find the maximum length of a special substring in ```s``` that is occuring atleast 3 times. A special substring is defined as a substring in which all characters are the same.\n\nWrite a function maximumLength to solve the problem.\n\n# Intuition\n<!-- Describ... | 15 | 0 | ['Hash Table', 'Sliding Window', 'Sorting', 'Python', 'C++', 'Java', 'Python3'] | 3 |
find-longest-special-substring-that-occurs-thrice-i | ✅ Java Solution | Easy to understand | java-solution-easy-to-understand-by-hars-7e9t | solution\n Save all the substrings, and it\'s counted in HashMap\n Iterate through all the strings in the map\n Check string contains the same characters and oc | Harsh__005 | NORMAL | 2023-12-31T04:10:29.576434+00:00 | 2023-12-31T04:10:29.576458+00:00 | 975 | false | ## solution\n* Save all the substrings, and it\'s counted in HashMap\n* Iterate through all the strings in the map\n* Check string contains the same characters and occurrences more than 3 times\n* Take the longest string as an answer\n\n## code\n```\npublic int maximumLength(String s) {\n\tint res = -1;\n\n\tchar[] arr... | 15 | 0 | ['Java'] | 6 |
find-longest-special-substring-that-occurs-thrice-i | [C++ & Java] Explained - Using only map O(N) & using binary search O(N.logN) solution | using-map-very-simple-and-easy-to-unders-imuw | Approach\n- track the continuous occurance count of each item in s\n- Keep pushing the occurance count in the map against that character\n- Now we have diff chu | kreakEmp | NORMAL | 2023-12-31T04:04:58.482260+00:00 | 2024-12-10T12:02:18.393562+00:00 | 4,161 | false | # Approach 1 ( using only map & storing the continuous chars group count) :\n- track the continuous occurance count of each item in s\n- Keep pushing the occurance count in the map against that character\n- Now we have diff chunk of occurance count in the map for each character\n- So keep checking each character\'s max... | 15 | 0 | ['C++', 'Java'] | 6 |
find-longest-special-substring-that-occurs-thrice-i | ✅ One Line Solution | one-line-solution-by-mikposp-a57p | null | MikPosp | NORMAL | 2024-12-10T11:12:41.764786+00:00 | 2024-12-10T21:29:50.658121+00:00 | 648 | false | (Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - Five Lines\nTime complexity: $$O(26n)$$. Space complexity: $$O(n)$$.\n```python3\nclass Solution:\n def maximumLength(self, s: str) -> int:\n res = -1\n for c in {*s}:\n ... | 12 | 0 | ['String', 'Python', 'Python3'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Freq count+nth_element vs size 3 arrays||Beats 100% | freq-countnth_element3ms-beats-9662-by-a-cpy3 | null | anwendeng | NORMAL | 2024-12-10T02:03:31.657556+00:00 | 2024-12-10T06:53:09.416743+00:00 | 269 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUse freq count & nth_element to solve.\n\nSame solution can also pass [2982. Find Longest Special Substring That Occurs Thrice II](https://leetcode.com/problems/find-longest-special-substring-that-occurs-thrice-ii/solutions/4483637/c-find... | 5 | 0 | ['Two Pointers', 'String', 'Counting', 'C++'] | 5 |
find-longest-special-substring-that-occurs-thrice-i | Simple Binary Search 100% Beats | simple-binary-search-100-beats-by-sumeet-j06x | null | Sumeet_Sharma-1 | NORMAL | 2024-12-10T01:11:52.528424+00:00 | 2024-12-10T01:18:37.828925+00:00 | 1,634 | false | # \uD83D\uDE80 Intuition \nWe are tasked with finding the **maximum length** \\( x \\) of a **special substring** that occurs at least **three times** in the given string `s`. \nA **special substring** contains only one unique character (e.g., `"aaa"`, `"bbbb"`). \nThe solution uses **binary search** combined with *... | 5 | 0 | ['Binary Search', 'C', 'C++', 'Java', 'Python3', 'Ruby', 'JavaScript', 'C#'] | 20 |
find-longest-special-substring-that-occurs-thrice-i | One pass | Beat 100% | one-pass-beat-100-by-quanhuy-7i5x | Complexity\n- Time complexity: O(N)\n\n# Code\n\nclass Solution:\n def maximumLength(self, s: str) -> int:\n last = s[0]\n cnt = 0\n d = | quanhuy | NORMAL | 2023-12-31T15:44:28.808491+00:00 | 2024-12-11T14:57:35.061637+00:00 | 362 | false | # Complexity\n- Time complexity: O(N)\n\n# Code\n```\nclass Solution:\n def maximumLength(self, s: str) -> int:\n last = s[0]\n cnt = 0\n d = defaultdict(list)\n\n for c in s:\n if c == last:\n cnt += 1\n else:\n cnt = 1\n ... | 4 | 0 | ['Hash Table', 'Heap (Priority Queue)', 'Python3'] | 3 |
find-longest-special-substring-that-occurs-thrice-i | C++ || sorting and binary search || map || explanation || optimized approach || Easy to understand | c-sorting-and-binary-search-map-explanat-qx73 | Intuition\n Describe your first thoughts on how to solve this problem. \n1. store the total count of the characters of the string in the array a \n2. sort all t | garima1609 | NORMAL | 2023-12-31T05:04:58.631917+00:00 | 2023-12-31T05:04:58.631946+00:00 | 242 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1. store the total count of the characters of the string in the array a \n2. sort all the characters \n3. apply binary search and check if a character\'s occurence is greater than 3 and then find the character with maximum count together ... | 4 | 0 | ['Binary Search', 'Ordered Map', 'Sorting', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | easy solution with explantaion (brute force approach) | easy-solution-with-explantaion-brute-for-tkof | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nLet\'s break down the code and understand the approach:\n\n Map Initia | pahadi_rawat | NORMAL | 2023-12-31T04:04:47.302686+00:00 | 2023-12-31T10:20:20.762532+00:00 | 771 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nLet\'s break down the code and understand the approach:\n\n Map Initialization:\n The code uses a std::map named mp to store substrings and their frequencies.\n temp is an empty string to store the current subs... | 4 | 0 | ['C++'] | 3 |
find-longest-special-substring-that-occurs-thrice-i | 💢☠💫Easiest👾Faster✅💯 Lesser🧠 🎯 C++✅Python3🐍✅Java✅C✅Python🐍✅C#✅💥🔥💫Explained☠💥🔥 Beats 100 | easiestfaster-lesser-cpython3javacpython-1tbx | null | Edwards310 | NORMAL | 2024-12-10T16:07:30.609062+00:00 | 2024-12-10T16:07:30.609062+00:00 | 303 | false | \n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n- ***JavaScript Code -->**... | 3 | 0 | ['Hash Table', 'C', 'Sliding Window', 'Python', 'C++', 'Java', 'Go', 'Python3', 'JavaScript', 'C#'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | simple and clean code | simple-and-clean-code-by-don_quixxote-xber | null | Don_quixxote | NORMAL | 2024-12-10T14:55:10.672851+00:00 | 2024-12-10T14:55:10.672851+00:00 | 70 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nmap to store - character\'s length and that length\'s count\nthen another map (while looping over one character)to store length\'s frequency \nfor string with length n... | 3 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Most Optimized with Time complexity of O(NLogN) and beats 99% user in runtime. 🔥🔥🔥 | most-optimized-with-time-complexity-of-o-v6dw | null | dev_bhatt202 | NORMAL | 2024-12-10T04:01:14.216238+00:00 | 2024-12-10T04:01:14.216238+00:00 | 154 | false | # Complexity\n- Time complexity: O(NLogN)\n\n\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```java []\npublic class Solution {\n public int maximumLength(Str... | 3 | 0 | ['Java'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | Python: Well Explained O(N) Solution Using Two Counters (Dictionaries) | python-well-explained-on-solution-using-9y7ay | Sep 16, 2024:\nRuntime beats 97.53% | Memory beats 47.58%\n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nNaive solution would be | PTLin84 | NORMAL | 2024-09-05T04:51:15.841904+00:00 | 2024-09-20T16:39:11.215828+00:00 | 315 | false | **Sep 16, 2024:**\nRuntime beats 97.53% | Memory beats 47.58%\n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nNaive solution would be to find all substrings, count the ones that are special (repeating one letter), and return the maximum length. However, this will very likely be too ... | 3 | 0 | ['Hash Table', 'Counting', 'Python3'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | O(n) Solution | Sliding Window | C++ | on-solution-sliding-window-c-by-darkaadi-h700 | Approach\n Describe your approach to solving the problem. \n1) Think about sliding window approach to consider substrings to find the longest special substring | darkaadityaa | NORMAL | 2024-01-02T16:51:35.107342+00:00 | 2024-01-02T16:51:35.107364+00:00 | 416 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n1) Think about sliding window approach to consider substrings to find the longest special substring according to conditons provided.\n\n2) Maintain a map to keep track of various substring and it\'s occurences. For each current substring into consider... | 3 | 0 | ['Hash Table', 'Sliding Window', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | BEATS 100% || RECURSIVE SOLUTION | bears-100-recursive-solution-by-shyam4kb-takf | 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 | shyam4KB | NORMAL | 2023-12-31T04:04:51.573520+00:00 | 2024-12-10T04:03:30.336758+00:00 | 28 | 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 | ['Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Easy and Clear Java Solution Using HashMap | easy-and-clear-java-solution-using-hashm-yhcm | 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 | 20R01A66D7 | NORMAL | 2023-12-31T04:03:35.842261+00:00 | 2023-12-31T04:03:35.842294+00:00 | 573 | 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 | ['Java'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | ✅ C++ | Brute Force | | c-brute-force-by-sirius_108-glkd | Approach\n Describe your approach to solving the problem. \nBrute Force\n\n# Code\n\nclass Solution {\npublic:\n int maximumLength(string s) {\n int N | sirius_108 | NORMAL | 2023-12-31T04:00:57.431050+00:00 | 2023-12-31T08:58:52.869463+00:00 | 244 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nBrute Force\n\n# Code\n```\nclass Solution {\npublic:\n int maximumLength(string s) {\n int N = s.length();\n for(int i = N-2; i>=1; i--)\n {\n for(char c = \'a\'; c<=\'z\'; c++)\n {\n int c... | 3 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | [Python3] - Very simple O(n) solution beats 100%, 0ms runtime 🔥🔥🔥 | python3-very-simple-on-solution-beats-10-dou3 | null | starlex | NORMAL | 2024-12-10T14:37:51.465157+00:00 | 2024-12-10T14:57:40.263656+00:00 | 50 | false | # Key Idea\nWe decompose the original string into runs of identical characters. For example, if s = "aaabaaa", we have runs (a,3), (b,1), (a,3). Each run (c, length) represents a contiguous segment of the character c repeated length times. For these segments we want to count how many times they appear in this case the ... | 2 | 0 | ['Hash Table', 'String', 'Counting', 'Python3'] | 2 |
find-longest-special-substring-that-occurs-thrice-i | C++ Code ✅✅ || Simple Approach✅✅ | c-code-simple-approach-by-yashm01-30al | null | yashm01 | NORMAL | 2024-12-10T11:42:52.870024+00:00 | 2024-12-10T11:42:52.870024+00:00 | 35 | false | # "Every solution starts with a thought, and every thought leads to a solution. \uD83D\uDCA1"\n\n# Intuition \uD83E\uDD14\nThe idea is to identify **"special substrings"** \uD83C\uDF1F, where all characters are the same. We will check every substring in the given string \uD83D\uDD0D and count the occurrences of these s... | 2 | 0 | ['Hash Table', 'String', 'Counting', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Simple & Efficient Substring Enumeration and Frequency Counting for Maximum Special Substring Length | simple-efficient-substring-enumeration-a-mq8v | null | anand_shukla1312 | NORMAL | 2024-12-10T08:48:11.757948+00:00 | 2024-12-10T08:48:11.757948+00:00 | 9 | false | # Complexity\n- Time complexity: $$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n^2)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n def maximumLength(self, s: str) -> int:\n # Create a dictionary to store freq... | 2 | 0 | ['Hash Table', 'String', 'Counting', 'Python3'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | 🔥BEATS 💯 % 🎯 |✨SUPER EASY BEGINNERS 👏 | beats-super-easy-beginners-by-codewithsp-t6ml | null | CodeWithSparsh | NORMAL | 2024-12-10T07:23:22.499982+00:00 | 2024-12-10T07:37:50.185149+00:00 | 239 | false | \n\n\n---\n\n\n\n---\n\n# Intuition\nTo solve the problem:\n1. We need to find the long... | 2 | 0 | ['Hash Table', 'String', 'C', 'Sliding Window', 'C++', 'Java', 'Go', 'Python3', 'JavaScript', 'Dart'] | 3 |
find-longest-special-substring-that-occurs-thrice-i | Simple Approach || Binary Search with hashmap | simple-approach-binary-search-with-hashm-7759 | null | akshatchawla1307 | NORMAL | 2024-12-10T06:17:47.386347+00:00 | 2024-12-10T06:17:47.386347+00:00 | 14 | false | # Intuition\n**Given that special substring should occur thrice, then the maxiumum size that it can hold is (n-2). Whereas minimum possible size is 1. So, i used binary search with start=1 and end-n-1 to check that whether any value in range(1,n-2) could be a possible solution or not.**\n<!-- Describe your first though... | 2 | 0 | ['Hash Table', 'Binary Search', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Simple Approach || Binary Search with hashmap | simple-approach-binary-search-with-hashm-aki8 | null | akshatchawla1307 | NORMAL | 2024-12-10T05:44:04.217878+00:00 | 2024-12-10T05:44:04.217878+00:00 | 6 | false | # Intuition\nGiven that special substring should occur thrice, then the maxiumum size that it can hold is (n-2). Whereas minimum possible size is 1. So, i used binary search with start=1 and end-n-1 to check that whether any value in range(1,n-2) could be a possible solution or not.\n<!-- Describe your first thoughts o... | 2 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | C++ || Brute Force | c-try-every-special-substring-by-ahmedsa-0hzo | null | AhmedSayed1 | NORMAL | 2024-12-10T00:21:29.654225+00:00 | 2024-12-10T01:48:12.098596+00:00 | 42 | false | \n# Explaining\n <h3> Try every special substrings and follow the comments between the code for more explaining </h3>\n\n# Complexity\n- <h3>O(n * n * log(n))</h3>\n\n# Code\n```cpp []\nclass Solution {\npublic:\n int maximumLength(string s) {\n map<string, int>mp;\n\n int ans = -1;\n for(int i... | 2 | 0 | ['Hash Table', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Easy Fully explained solution | Sliding Window + Binary Search | O(nlogn) solution | easy-fully-explained-solution-sliding-wi-nlg1 | Intuition\nThe problem is about finding the maximum length of a substring that appears at least three times in a given string s. The core intuition is to use a | sakshamsharma809 | NORMAL | 2024-08-24T10:14:56.814229+00:00 | 2024-08-24T10:16:45.092453+00:00 | 67 | false | # Intuition\nThe problem is about finding the maximum length of a substring that appears at least three times in a given string s. The core intuition is to use a sliding window approach to check for repeating substrings and then use binary search to efficiently find the maximum length of such substrings.\n\n# Approach\... | 2 | 0 | ['Hash Table', 'String', 'Binary Search', 'Sliding Window', 'Counting', 'Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | BEATS 97%|| EASY || 3STEPS|| Same as 2982 | beats-97-easy-3steps-same-as-2982-by-abh-dre1 | Intuition\n Describe your first thoughts on how to solve this problem. \n# THE SAME CODE WILL WORK FOR 2982 ON LEETCODE AS WELL.\nThis code determines the maxim | Abhishekkant135 | NORMAL | 2024-01-09T08:45:18.739519+00:00 | 2024-01-09T08:45:18.739551+00:00 | 787 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n# THE SAME CODE WILL WORK FOR 2982 ON LEETCODE AS WELL.\nThis code determines the maximum length of a substring that can be formed by deleting at most one character from the input string s, such that the substring contains only one distin... | 2 | 0 | ['Hash Table', 'Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | [C++] Brute Force, Try All Possible Special Substring | c-brute-force-try-all-possible-special-s-ntz0 | Intuition\n Describe your first thoughts on how to solve this problem. \n- Try all possible special substring\n- Get the occurrence of the special substring\n\n | pepe-the-frog | NORMAL | 2024-01-03T04:06:06.829823+00:00 | 2024-01-03T04:06:06.829853+00:00 | 588 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- Try all possible special substring\n- Get the occurrence of the special substring\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Slide the window with width `len`\n- Count the occurrence of the special substri... | 2 | 0 | ['Sliding Window', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Are You Special❓|| T.C. : O(n^3) || S.C. : (n) | are-you-special-tc-on3-sc-n-by-algorhyth-9vl3 | Intuition\n Describe your first thoughts on how to solve this problem. \n- Given a string s, we have to return the maximum length of special substring that occu | AlgoRhythmic_Minds | NORMAL | 2024-01-01T17:13:14.865340+00:00 | 2024-01-02T13:47:36.024906+00:00 | 406 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- Given a string s, we have to return the maximum length of special substring that occurs at least thrice time in a string s.\n- A special substring is a string having all the same characters. \n\n# Approach\n<!-- Describe your approach t... | 2 | 0 | ['Ordered Map', 'C++'] | 2 |
find-longest-special-substring-that-occurs-thrice-i | ✅✅✅Beats 100% using HashMap in java | beats-100-using-hashmap-in-java-by-jaiva-84rx | Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires to check longest special substring which occurs thrice or more. To | jaivant_manki | NORMAL | 2023-12-31T15:22:56.549078+00:00 | 2024-01-01T11:48:17.172934+00:00 | 30 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires to check longest special substring which occurs thrice or more. To find this out we have to check all the possible substrings that can be formed and the number of times they occur. Thus we need to find a way to keep t... | 2 | 0 | ['Hash Table', 'Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Keeping Top 3 Lengths in a Static Array. O(N). No Vectors. C++ 0 ms, Java 1 ms. Beating 100%. | keeping-top-3-lengths-in-a-static-array-qegkj | Intuition\n\nActually this task has been first solved using a prefix tree-based square-complexity algorithm to count substrings. That solution was too generic a | sergei99 | NORMAL | 2023-12-31T12:42:29.421900+00:00 | 2024-12-10T02:51:40.185761+00:00 | 263 | false | # Intuition\n\nActually this task has been first solved using a prefix tree-based square-complexity algorithm to count substrings. That solution was too generic and too slow (21 ms vs top 4 ms at the moment). So we have adapted the linear solution here.\n\nAll the background can be found in [the solution to the second ... | 2 | 1 | ['Array', 'String', 'Sorting', 'Counting', 'C++', 'Java', 'Scala'] | 3 |
find-longest-special-substring-that-occurs-thrice-i | ON^3 - Brute Force + Explanation | on3-brute-force-explanation-by-biggesto-85pu | Intuition\nCreate dictionary that holds all possible special single characters. While iterating through the string, keep count of how many times any special sin | biggesto | NORMAL | 2023-12-31T08:57:12.308084+00:00 | 2024-06-15T15:30:11.193132+00:00 | 317 | false | # Intuition\nCreate dictionary that holds all possible special single characters. While iterating through the string, keep count of how many times any special single characters appear. \n\n# Approach\nCreate a dictionary and set return value of -1 initially. \n\nIterate through the string with a nested for loop to go t... | 2 | 0 | ['Python', 'Python3'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | ✅ C++ | Brute Force | Map | c-brute-force-map-by-harshadkhandare9000-1u60 | 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 | harshadkhandare9000 | NORMAL | 2023-12-31T06:50:29.101963+00:00 | 2023-12-31T06:50:29.101983+00:00 | 154 | 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 |
find-longest-special-substring-that-occurs-thrice-i | C++ SIMPLE AND OPTIMAL SOLUTION FOR BEGNNERS USING HASHMAP :) | c-simple-and-optimal-solution-for-begnne-flon | Intuition\n Describe your first thoughts on how to solve this problem. \nFIND FREQ AND MAKE A COUNT FOR THE NO. OF TIMES THAT FREQ CAME FOR EVERY CHAR\nTHEN CAL | Dhiraj_Mohata | NORMAL | 2023-12-31T05:07:53.338903+00:00 | 2023-12-31T05:07:53.338929+00:00 | 161 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFIND FREQ AND MAKE A COUNT FOR THE NO. OF TIMES THAT FREQ CAME FOR EVERY CHAR\nTHEN CALCUALATE THE ANS BY MAX BY THIS STEPS FOR ALL FREQ:\na) FREQ - 2;\nb) CHECK IF WE HAVE GEATER FREQ AVALABLE OR NOT\nc) IF WE HAVE SAME FREQ 2 TIMES THEN... | 2 | 0 | ['Hash Table', 'Greedy', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Brute Force || check for each substring | brute-force-check-for-each-substring-by-7gopj | Code\n\nclass Solution {\npublic:\n bool same(string s){\n sort(s.begin(), s.end());\n return s[0]==s.back();\n }\n bool has(string &s, i | calm_porcupine | NORMAL | 2023-12-31T04:02:09.198481+00:00 | 2023-12-31T04:02:09.198509+00:00 | 570 | false | # Code\n```\nclass Solution {\npublic:\n bool same(string s){\n sort(s.begin(), s.end());\n return s[0]==s.back();\n }\n bool has(string &s, int n){\n unordered_map<string, int>mp;\n for(int i = 0;i+n<=s.length();i++){\n string aux = s.substr(i, n);\n if(same(... | 2 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Brute Force Trying all the sub-strings | brute-force-trying-all-the-sub-strings-b-j0li | 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 | Minato_10 | NORMAL | 2023-12-31T04:01:50.062294+00:00 | 2023-12-31T04:01:50.062319+00:00 | 321 | 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 | ['Ordered Map', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Easy HashMap solution | Java | easy-hashmap-solution-java-by-hee_maan_s-nakt | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | hee_maan_shee | NORMAL | 2025-01-19T08:24:33.240906+00:00 | 2025-01-19T08:24:33.240906+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 | ['Hash Table', 'Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Well Explained & Optimal Solution even for higher constraint like leetcode 2982 || Runs 0ms | well-explained-optimal-solution-even-for-vddo | This Solution can also work fine on Leetcode 2982Find Longest Special Substring That Occurs Thrice II: https://leetcode.com/problems/find-longest-special-substr | Harsh-X | NORMAL | 2025-01-10T01:36:49.248239+00:00 | 2025-01-10T01:36:49.248239+00:00 | 30 | false | 
##### This Solution can also work fine on Leetcode 2982
**Find Longest Special Substring That Occurs Thrice II**: [https://leetcode.com/problems/find-longest-special-substring-that-occurs-thrice-ii/descri... | 1 | 0 | ['Array', 'String', 'Counting', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Easy Python Solution (easy to understand) | easy-python-solution-easy-to-understand-b0r9k | ```\nclass Solution:\n def maximumLength(self, s: str) -> int:\n hsh={}\n for i in range(len(s)):\n for j in range(i+1,len(s)+1):\n | gokulram2221 | NORMAL | 2024-12-10T12:30:47.266904+00:00 | 2024-12-10T12:30:47.266948+00:00 | 31 | false | ```\nclass Solution:\n def maximumLength(self, s: str) -> int:\n hsh={}\n for i in range(len(s)):\n for j in range(i+1,len(s)+1):\n if s[i:j] in hsh.keys() :\n hsh[s[i:j]]+=1\n else:\n hsh[s[i:j]]=1\n mx=-1\n r... | 1 | 0 | [] | 1 |
find-longest-special-substring-that-occurs-thrice-i | Simple Solution | Sliding window | 94% Beats in Memory | C++ | simple-solution-sliding-window-94-beats-0i7tw | Self explanatory code:\n\n\nclass Solution {\npublic:\n \n int maximumLength(string s) \n {\n int n = s.size();\n int ans = -1;\n | tirth_rami | NORMAL | 2024-12-10T05:50:40.370532+00:00 | 2024-12-10T05:50:40.370573+00:00 | 12 | false | Self explanatory code:\n\n```\nclass Solution {\npublic:\n \n int maximumLength(string s) \n {\n int n = s.size();\n int ans = -1;\n int i=0, j= 0;\n while(j < n)\n {\n // take substring from i to j\n string ola = s.substr(i,j-i+1);\n int cnt ... | 1 | 0 | ['C', 'Sliding Window'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Not that fast, but simple to understand with Priority Queue | not-that-fast-but-simple-to-understand-w-x3qg | null | wildclown | NORMAL | 2024-12-10T22:03:25.832027+00:00 | 2024-12-10T22:03:25.832027+00:00 | 15 | false | # \uD83D\uDE80 Intuition\n### After a while trying to understand the problem, saw that in order to get certain letter value, there was a pattern... Now I was only in need of how to find its max... To find it I used a\n\n# \uD83E\uDDE0 Approach\n#### Two pointers with Max Priority Queue! Would place the letters windows ... | 1 | 0 | ['Sliding Window', 'Heap (Priority Queue)', 'JavaScript'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | 🚀✅Optimize Solution✅ || ✅beats 100% in both TC and SC✅🚀💯 | optimize-solution-beats-100-in-both-tc-a-ibnr | null | R_Patel_007 | NORMAL | 2024-12-10T19:28:39.567750+00:00 | 2024-12-10T19:28:39.567750+00:00 | 7 | false | # \uD83E\uDDE0 Intuition \nWhen solving this problem, the idea is to find the **maximum length of substrings** that satisfy a specific condition using **binary search** and **bit manipulation**. We\u2019ll use a sliding window and a frequency map to track substrings dynamically. \uD83D\uDE80 \n\n---\n\n# \uD83D\uDD0D... | 0 | 0 | ['Hash Table', 'String', 'Binary Search', 'Sliding Window', 'Counting', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Easy Code and very Simple , you can say brute Force | easy-code-and-very-simple-you-can-say-br-yq2t | null | AtithiShekhar1 | NORMAL | 2024-12-10T11:28:21.859911+00:00 | 2024-12-10T11:28:21.859911+00:00 | 6 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nthe time and space are not good but the code is simple and easy to unserstand \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\ni created 3 functions , one is main function provided by leetcode which will check if s... | 1 | 0 | ['Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Simple Readable | Linear Time O(N) | Constant O(1) space | PQ | simple-readable-linear-time-on-constant-satkn | null | Apakg | NORMAL | 2024-12-10T11:13:55.686264+00:00 | 2024-12-10T11:13:55.686264+00:00 | 18 | false | # Code\n```java []\nclass Solution {\n public int maximumLength(String s) {\n PriorityQueue<Integer>[] all = new PriorityQueue[26];\n for (int i = 0; i < 26; i++) {\n all[i] = new PriorityQueue<>();\n }\n\n char last = \'?\';\n int n = 0;\n for (char ch : s.toChar... | 1 | 0 | ['Array', 'Heap (Priority Queue)', 'Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | best code in java | best-code-in-java-by-notaditya09-2ha8 | null | NotAditya09 | NORMAL | 2024-12-10T09:07:09.862643+00:00 | 2024-12-10T09:07:09.862643+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)$$ --... | 1 | 0 | ['Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Easiest Python Solution | easiest-python-solution-by-sumittripathi-z1bc | null | sumittripathi004 | NORMAL | 2024-12-10T08:43:05.479136+00:00 | 2024-12-10T08:43:05.479136+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^2)$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $O(N^2)$\n<!-- Add your space complexity here... | 1 | 0 | ['Hash Table', 'String', 'Counting', 'Python3'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | easy to understand simple brute force not sliding window | easy-to-understand-simple-brute-force-no-4w8c | null | codedominator7 | NORMAL | 2024-12-10T06:53:25.104854+00:00 | 2024-12-10T06:53:25.104854+00:00 | 113 | false | # Intuition\nbrute forse will work try to simulate the question you can generate all possible substring to solve it \n\n# Approach\n1)you will generate all possible substring\n2)iterate in map and check if the subtring count is greater than 3\n3)if yes then check if special \n4)store its lenght in ans variable\n\n# Cod... | 1 | 0 | ['Hash Table', 'String', 'Simulation', 'Counting', 'C++'] | 7 |
find-longest-special-substring-that-occurs-thrice-i | Simple Solution | Using HashMap | Java ✅✅ | simple-solution-using-hashmap-java-by-ab-3kok | null | abhinavtilwar1501 | NORMAL | 2024-12-10T06:49:45.375701+00:00 | 2024-12-10T06:49:45.375701+00:00 | 20 | false | \n# Complexity\n- Time complexity: $$O(n^2)$$ \n\n- Space complexity: $$O(m)$$ $$m$$ $$is$$ $$the$$ $$size$$ $$of$$ $$hashtable$$\n\n# Code\n```java []\nclass Solution {\n public int maximumLength(String s) {\n int max = -1;\n HashMap<String,Integer> map=new HashMap();\n int[] freq=new int[26];\... | 1 | 0 | ['Hash Table', 'String', 'Sliding Window', 'Counting', 'Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | C++ Sliding Window + Map Solution | O(N) - Time | O(k * N) - Space | c-sliding-window-map-solution-on-time-ok-u7q8 | null | lakshyamahawar14 | NORMAL | 2024-12-10T06:36:13.312266+00:00 | 2024-12-10T06:36:13.312266+00:00 | 12 | false | # Intuition\nNote that a special string have all of its characters same, hence we only need to consider such substrings. We can apply sliding window approach here.\n\n# Approach\nA string of length n (>= 3) will have a substring of length (n - 2) appear thrice, hence we\'ve got one of our answer and we don\'t need to w... | 1 | 0 | ['Ordered Map', 'Sliding Window', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Simple and Easy to Understand HashMap Solution || With Explanation || Clean Code | simple-and-easy-to-understand-hashmap-so-43ig | null | dhruvdangi03 | NORMAL | 2024-12-10T06:16:30.391652+00:00 | 2024-12-10T06:16:30.391652+00:00 | 4 | false | \n\n# Code\n```java []\nclass Solution {\n public int maximumLength(String s) {\n // First create a HashMap\n HashMap<String, Integer> freq = new HashMap<>();\n\n // Then loop through the String \n for(int i = 0; i < s.length(); i++){\n // Store the current character\n ... | 1 | 0 | ['Hash Table', 'String', 'Counting', 'Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | C++ O(26N) Solution without Binary Search | c-o26n-solution-by-retire-m2sg | null | Retire | NORMAL | 2024-12-10T05:13:26.908855+00:00 | 2024-12-10T05:15:02.720960+00:00 | 18 | false | # Code\n```cpp []\nclass Solution {\npublic:\n int maximumLength(string s) {\n int n = s.size();\n vector<vector<int>> cnt(26, vector<int>(n + 1, 0));\n int l = 0, r = 0;\n while (r < n) {\n if (s[l] != s[r]) {\n cnt[s[l] - \'a\'][r - l] += 1;\n l ... | 1 | 0 | ['Counting', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | [C++] Simple implementation, check for every length substring occurences | c-simple-implementation-check-for-every-ew82k | null | bora_marian | NORMAL | 2024-12-10T05:10:01.207335+00:00 | 2024-12-10T05:10:01.207335+00:00 | 15 | false | Check every for every length the number of substring occurrences which has only 1 character. If the number of occurrences >= 3 then this length is our result.\n# Code\n```cpp []\nclass Solution {\npublic:\n int maximumLength(string s) {\n int n = s.size(), res = -1;\n for (int l = 1; l <= n; l++) {\n ... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | C# Solution for Find Longest Special Substring That Occurs Thrice I Problem | c-solution-for-find-longest-special-subs-dko6 | null | Aman_Raj_Sinha | NORMAL | 2024-12-10T04:56:17.522457+00:00 | 2024-12-10T04:56:17.522457+00:00 | 13 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe goal is to find the longest special substring (a substring made up of identical characters) that appears at least three times. Since longer substrings are harder to satisfy the condition of occurring thrice, we can use binary search o... | 1 | 0 | ['C#'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | Java Solution for Find Longest Special Substring That Occurs Thrice I Problem | java-solution-for-find-longest-special-s-3m95 | null | Aman_Raj_Sinha | NORMAL | 2024-12-10T04:49:18.085297+00:00 | 2024-12-10T04:49:18.085297+00:00 | 57 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem involves finding the longest special substring that appears at least three times in a given string. A substring is considered special if all its characters are the same. The key observations are:\n1.\tFor a substring to be val... | 1 | 0 | ['Java'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | 🚀 C++ Solution 🔥Beats 100%🔥Clean Code with Intuition & Approach | c-solution-beats-100-clean-code-with-int-3bmq | null | fakhrulsojib | NORMAL | 2024-12-10T04:37:48.966299+00:00 | 2024-12-10T04:40:31.454054+00:00 | 6 | false | # Intuition \nThe key observation is that the answer depends on the **three longest segments** of each character. If the sizes of these segments are `x`, `y`, and `z` (with `x <= y <= z`), the result must satisfy: `answer >= min(x, y, z)`\n\n# Approach \n1. For each character, collect the sizes of its consecutive seg... | 1 | 0 | ['Greedy', 'Counting', 'C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | simple approach without using any complex algorithm like binarysearch ✅📈 | simple-approach-without-using-any-comple-1qim | null | arikaran__r | NORMAL | 2024-12-10T04:16:26.071053+00:00 | 2024-12-10T04:16:26.071053+00:00 | 5 | false | # Approach\nThe goal of this code is to find the maximum length of a substring in the input string s where\n\n* The substring consists of repeated characters.\n* The substring must appear more than twice in s\n\nIf no such substring exists, it checks if there is any character that appears more than twice in s. If f... | 1 | 0 | ['Hash Table', 'Sliding Window', 'Counting', 'C++', 'Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | simple approach without using any complex algorithm like binarysearch ✅📈 | simple-approach-without-using-any-comple-tabg | null | arikaran__r | NORMAL | 2024-12-10T03:57:17.478157+00:00 | 2024-12-10T03:57:17.478157+00:00 | 9 | false | # Approach\nThe goal of this code is to find the maximum length of a substring in the input string s where\n\n* The substring consists of repeated characters.\n* The substring must appear more than twice in s\n\nIf no such substring exists, it checks if there is any character that appears more than twice in s. If fo... | 1 | 0 | ['Hash Table', 'Sliding Window', 'Counting', 'C++', 'Java', 'Python3'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | ✅✅Beats 100%🔥C++🔥Python|| 🚀🚀Super Simple and Efficient Solution🚀🚀||🔥Python🔥C++✅✅ | beats-100cpython-super-simple-and-effici-5tkd | null | shobhit_yadav | NORMAL | 2024-12-10T03:56:40.222525+00:00 | 2024-12-10T03:56:40.222525+00:00 | 49 | false | # Complexity\n- Time complexity:$$O(26n)=O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(26n)=O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\n public:\n int maximumLength(string s) {\n const int n = s.length();\n int a... | 1 | 0 | ['C++', 'Python3'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | Simple O(n) approach | Kotlin | simple-on-approach-kotlin-by-sanskarpati-nhh0 | NoteHere i used temp as string but you can use stringbuilder.
(Strings in Kotlin are immutable, so every time you modify a string (e.g., by appending characters | sanskarpatidar | NORMAL | 2024-12-10T03:49:11.646439+00:00 | 2024-12-14T05:02:36.594695+00:00 | 9 | false | # Note\n Here i used temp as string but you can use stringbuilder.\n(Strings in Kotlin are immutable, so every time you modify a string (e.g., by appending characters), a new string object is created. This can lead to unnecessary memory allocation and copying.)\n+= Concatenation --> O(n)\n.append() --> O(1)\n# Complex... | 1 | 0 | ['Hash Table', 'String', 'Counting', 'Kotlin'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Easy Solution in C++ | easy-solution-in-c-by-dhanu07-92b9 | null | Dhanu07 | NORMAL | 2024-12-10T02:52:57.869348+00:00 | 2024-12-10T02:52:57.869348+00:00 | 16 | 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)$$ --... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Rust binary search solution | rust-binary-search-solution-by-sunjesse-nuvh | null | sunjesse | NORMAL | 2024-12-10T02:37:04.670648+00:00 | 2024-12-10T02:37:04.670648+00:00 | 2 | false | # Code\n```rust []\nimpl Solution {\n fn val(x: usize, s: &Vec<u8>, n: &usize) -> bool {\n let mut cnt: Vec<usize> = vec![0; 26];\n let mut p: usize = 0;\n for i in 0..*n {\n while s[p] != s[i] { p += 1; }\n if (i - p + 1 >= x) { cnt[(s[i] - 97) as usize] += 1; }\n ... | 1 | 0 | ['Rust'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | Simple O(nlog(n)) solution, with explanaion | simple-ologn-solution-with-explanaion-by-wzvt | IntuitionFinding the longest special substring can be challenging. It is much simpler to check if a special substring of any given length appears 3 times. If a | Conrad_123 | NORMAL | 2024-12-10T02:16:39.548269+00:00 | 2024-12-16T04:51:16.900460+00:00 | 7 | false | # Intuition\nFinding the longest special substring can be challenging. It is much simpler to check if a special substring of any given length appears 3 times. If a special substring of a given length appears 3 times, then that is the longest special substring or a larger substring exists. Therefore we can preform a bin... | 1 | 0 | ['C++'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | Simple Binary Search 100% Beats | simple-binary-search-100-beats-by-optimi-dxbg | null | Optimizor | NORMAL | 2024-12-10T02:15:44.658787+00:00 | 2024-12-10T02:15:44.658787+00:00 | 17 | false | # Code\n```cpp []\nclass Solution {\npublic:\n int maximumLength(string s) {\n int n = s.size();\n int l = 1, r = n;\n\n if (!helper(s, n, l)) return -1;\n\n while (l + 1 < r) {\n int mid = (l + r) / 2;\n if (helper(s, n, mid)) l = mid;\n else r = mid;\n ... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Easy Explanation!! | easy-explanation-by-shailyintech-817d | null | ShailyInTech | NORMAL | 2024-12-10T02:02:33.922106+00:00 | 2024-12-10T02:02:33.922106+00:00 | 6 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nBinary Search for the Maximum Length:\n\nUse binary search to find the longest length of a "special substring" that occurs at least three times. This narrows down the ... | 1 | 0 | ['Binary Search', 'Sliding Window', 'Python3'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | O(nlogn) solution | onlogn-solution-by-yec0807-f755 | null | yenc0807 | NORMAL | 2024-12-10T01:34:39.237717+00:00 | 2024-12-10T01:34:39.237717+00:00 | 6 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nsince you only need to consider the same character, you can simplify it into 26 arrays with amounts of substrings\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\ngo through the string once and generate the array\ng... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | C++ Truly O(n) optimal solution | c-truly-on-optimal-solution-by-ningck-mnvo | null | Ningck | NORMAL | 2024-12-10T00:55:25.591871+00:00 | 2024-12-10T00:55:25.591871+00:00 | 13 | false | With the constraints being low, O(n) vs O(n^2) does not shine as much through the runtime but for bigger constraints this is much better.\n\n# Code\n```cpp []\nclass Solution {\npublic:\n int maximumLength(string s) {\n map<pair<char, int>, int> specialStrToCount;\n for (int l=0; l<s.length(); ++l) {\n... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | by using substr function and using map | by-using-substr-function-and-using-map-b-fsxy | 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 | 2004sherry | NORMAL | 2024-04-10T15:13:36.412465+00:00 | 2024-04-10T15:13:36.412504+00:00 | 24 | 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)$$ --... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Java O(N) simple sliding window like approach | java-on-simple-sliding-window-like-appro-ggcg | Intuition\nSliding window\n\n# Approach\nLet N be the largest substring for a given character. Let K be all substrings of size 1 to N. Then the number of subst | warland | NORMAL | 2024-03-06T18:51:22.590204+00:00 | 2024-03-08T13:34:54.793279+00:00 | 13 | false | # Intuition\nSliding window\n\n# Approach\nLet N be the largest substring for a given character. Let K be all substrings of size 1 to N. Then the number of substrings that can be formed for a substring of size N with K size is: N - K + 1.\n\n# Complexity\n- Time complexity:\n$$O(N)$$\n\n- Space complexity:\n$$O(N)$$\n... | 1 | 0 | ['Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | easy to understand ,beginners level code ,brute force | easy-to-understand-beginners-level-code-z92vl | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n1.using substring() ins | vigneshbangaru69 | NORMAL | 2024-02-27T18:24:15.610981+00:00 | 2024-02-27T18:24:15.611041+00:00 | 29 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.using substring() insert the strings into the hashmap and count the frequencys(in other words it is the length of the substring) of different lengths\n2.if the lengt... | 1 | 0 | ['Hash Table', 'String', 'Counting', 'Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | sliding window, and hashmap | sliding-window-and-hashmap-by-wxs2204-ri2h | Intuition\n Describe your first thoughts on how to solve this problem. \nUse a map to count the occurance of each special substring\n\n# Approach\n Describe you | wxs2204 | NORMAL | 2024-02-15T04:42:06.807686+00:00 | 2024-02-15T04:42:06.807715+00:00 | 75 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUse a map to count the occurance of each special substring\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. find a interval with identical char c, with length n\n2. special substring will can be c, cc, ccc, ... n... | 1 | 0 | ['Hash Table', 'Sliding Window', 'Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Easy C++ Solution | easy-c-solution-by-anshuljhamb16-uidm | 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 | anshuljhamb16 | NORMAL | 2024-01-08T18:29:09.373921+00:00 | 2024-01-08T18:29:09.374030+00:00 | 45 | 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)$$ --... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Only math | No binary search, no brute-force | 3 ms - faster than 99.73% solutions | simple-python3-solutions-40-ms-faster-th-wxkq | 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 here, e.g. O(n) \n\n# Co | tigprog | NORMAL | 2024-01-03T18:56:59.095907+00:00 | 2024-12-10T10:03:37.576143+00:00 | 261 | false | # 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 here, e.g. $$O(n)$$ -->\n\n# Code\n``` python3 []\n# base solution\n\nfrom itertools import groupby\n\nclass Solution:\n def maximumLength(self, s: str) -> ... | 1 | 0 | ['Hash Table', 'Math', 'Python3'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | Python3 | Intuitive. | python3-intuitive-by-yutaokkotsu-7504 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n- Use two pointers that scans a substring within string, s.\n- Record the substring, | yutaokkotsu | NORMAL | 2024-01-02T00:21:27.122155+00:00 | 2024-01-02T02:32:49.554517+00:00 | 15 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n- Use two pointers that scans a substring within string, `s`.\n- Record the substring, and its frequency, inside a hashmap\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n<ins>Three-steps</ins>\n\n(1) Use a has... | 1 | 0 | ['Array', 'Hash Table', 'Python3'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | C++ || Very Easy Approach | c-very-easy-approach-by-mrigank_2003-wih9 | \n\n# Code\n\nclass Solution {\npublic:\n int maximumLength(string s) {\n map<string, int>mp;\n for(int i=0; i<s.size(); i++){\n cha | mrigank_2003 | NORMAL | 2023-12-31T17:36:03.823337+00:00 | 2023-12-31T17:36:03.823367+00:00 | 54 | false | \n\n# Code\n```\nclass Solution {\npublic:\n int maximumLength(string s) {\n map<string, int>mp;\n for(int i=0; i<s.size(); i++){\n char a=s[i];\n int j=i;\n mp[s.substr(i, 1)]++;\n j++;\n while(j<s.size() && s[j]==a){\n mp[s.substr(... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Simple O(N) Solution Using Map | Intuition Explained | C++ | simple-on-solution-using-map-intuition-e-fj39 | Intuition\n\n- If same chars length == k , then we have : \n - 1 strings of length = k-0 \n - 2 strings of length = k-1 \n - 3 strings of length = k-2 \n | Jay_1410 | NORMAL | 2023-12-31T13:25:13.397713+00:00 | 2023-12-31T13:25:13.397741+00:00 | 38 | false | # Intuition\n\n- If same chars length == k , then we have : \n - 1 strings of length = k-0 \n - 2 strings of length = k-1 \n - 3 strings of length = k-2 \n - We dont care about strings of length = k-3 , k-4 , . . . etc .\nas the we already got a special string of length = k-2 .\n\n# Code\n```\nclass Solution {... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | cpp easy solution using three vector TC- O(N) SC-O(1) | cpp-easy-solution-using-three-vector-tc-8jfv9 | 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 | dr110801 | NORMAL | 2023-12-31T10:43:13.130026+00:00 | 2023-12-31T10:43:13.130058+00:00 | 13 | 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)$$ --... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Use O(26 * 3) array and O(n) time - 81 ms | use-o26-3-array-and-on-time-81-ms-by-efo-tb4r | Approach\nSave top 3 counts in decreasing order per each letter, now we can get min from three ababac (1), min from first shared and second aaba (1), or first s | eforce | NORMAL | 2023-12-31T07:06:42.695503+00:00 | 2023-12-31T07:08:15.533265+00:00 | 29 | false | # Approach\nSave top 3 counts in decreasing order per each letter, now we can get min from three `ababac` (1), min from first shared and second `aaba` (1), or first shared accross three `aaaa` (2).\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$ // 26 * 3\n\n# Code\n```\n/**\n * @param {s... | 1 | 0 | ['JavaScript'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | [JAVA] Beats 100% simple approach using Set. | java-beats-100-simple-approach-using-set-wb3s | \n\n\n# Approach \uD83D\uDCA1\n Describe your approach to solving the problem. \nDivide String into sub-parts and check the possibility of each String that is p | Codersoon | NORMAL | 2023-12-31T05:11:08.183755+00:00 | 2023-12-31T05:14:06.801550+00:00 | 51 | false | \n\n\n# Approach \uD83D\uDCA1\n<!-- Describe your approach to solving the problem. -->\nDivide String into sub-parts and check the possibility of each String that is present in input sub-string 3 time. chec... | 1 | 0 | ['Java'] | 2 |
find-longest-special-substring-that-occurs-thrice-i | 🧽 Java Clean & Simple | Sliding Window O(n) | java-clean-simple-sliding-window-on-by-p-e72c | Approach\nUsing Sliding Window to slide over it to get the continuous lenght, save it to the map (A 2D array int[][] map = new int[26][s.length()];)\n\nlast, ch | palmas | NORMAL | 2023-12-31T04:48:08.199713+00:00 | 2024-07-28T04:25:39.067878+00:00 | 121 | false | # Approach\nUsing Sliding Window to slide over it to get the continuous lenght, save it to the map (A 2D array ```int[][] map = new int[26][s.length()];```)\n\nlast, check if it have appear three time and compare the length to other which have appear three time.\n\n\n\n# Optimization\nAs example of "aaaa", when looping... | 1 | 0 | ['Java'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | Java || Beats 100% of the solutions ✅ ✅ ✅ | java-beats-100-of-the-solutions-by-ritab-d0re | \n\n# Code\n\nclass Solution {\n public int maximumLength(String s) {\n HashMap<String,Integer>map=new HashMap<>();\n int n=s.length();\n | Ritabrata_1080 | NORMAL | 2023-12-31T04:38:31.817278+00:00 | 2023-12-31T04:38:31.817297+00:00 | 30 | false | \n\n# Code\n```\nclass Solution {\n public int maximumLength(String s) {\n HashMap<String,Integer>map=new HashMap<>();\n int n=s.length();\n for(int i=0;i<n;i++){\n String str="";\n for(int j=i;j<n;j++){\n str+=s.charAt(j);\n if(special(str)){\... | 1 | 0 | ['Hash Table', 'Java'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | Clear clean details Explanation : find-longest-special-substring-that-occurs-thrice-I and II | clear-clean-details-explanation-find-lon-w3ac | \n\n\n\n# Complexity\n- Time complexity:\nO(n)\n\n\n\n# Code\n\npublic class Solution {\n public static int maximumLength(String input) {\n // Map to | Dheerajkumar9631r | NORMAL | 2023-12-31T04:06:54.367338+00:00 | 2023-12-31T04:08:26.830838+00:00 | 16 | false | \n\n\n\n# Complexity\n- Time complexity:\nO(n)\n\n\n\n# Code\n```\npublic class Solution {\n public static int maximumLength(String input) {\n // Map to store counts of special substrings\n Map<String, Integer> specialSubstringCountMap = new HashMap<>();\n\n // Length of the input string\n ... | 1 | 0 | ['Java'] | 1 |
find-longest-special-substring-that-occurs-thrice-i | sliding window solution c++ | sliding-window-solution-c-by-yashgarala2-wx3r | Intuition\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(n^2)\n Add your space complexity here, e.g. | yashgarala29 | NORMAL | 2023-12-31T04:02:40.352844+00:00 | 2023-12-31T04:02:40.352888+00:00 | 36 | false | # Intuition\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n^2)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n bool countWindo(string &s,int c){\n /*\n this method will count ... | 1 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Easy Python Solution | easy-python-solution-by-_suraj__007-gst8 | Code\n\nclass Solution:\n def maximumLength(self, s: str) -> int:\n if len(set(s))==len(s):\n return -1\n for i in range(len(s)-3,-1 | _suraj__007 | NORMAL | 2023-12-31T04:01:18.321763+00:00 | 2023-12-31T04:01:18.321797+00:00 | 185 | false | # Code\n```\nclass Solution:\n def maximumLength(self, s: str) -> int:\n if len(set(s))==len(s):\n return -1\n for i in range(len(s)-3,-1,-1):\n d = {}\n count = 0\n for j in range(i,len(s)):\n if len(set(s[count:j+1]))==1:\n ... | 1 | 0 | ['Python3'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Java | java-by-soumya_699-7729 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Soumya_699 | NORMAL | 2025-04-09T07:01:34.582782+00:00 | 2025-04-09T07:01:34.582782+00:00 | 0 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Java | java-by-soumya_699-c7m3 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Soumya_699 | NORMAL | 2025-04-09T07:01:29.946604+00:00 | 2025-04-09T07:01:29.946604+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 |
find-longest-special-substring-that-occurs-thrice-i | Longest Repeated Character Substring Occurring Thrice | longest-repeated-character-substring-occ-3283 | IntuitionInitial thought was to identify all substrings in the input string that consist of a single repeated character (e.g., "aaa" or "bb"), since these are t | t0ny1601 | NORMAL | 2025-04-05T09:10:14.063878+00:00 | 2025-04-05T09:10:14.063878+00:00 | 1 | false | # Intuition
Initial thought was to identify all substrings in the input string that consist of a single repeated character (e.g., "aaa" or "bb"), since these are the "special substrings" defined by the problem. The goal is to find the longest such substring that appears at least three times. A key observation is that w... | 0 | 0 | ['String', 'Java'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | 7 ms Beats 72.70% | 7-ms-beats-7270-by-red_viper-xrer | Code | red_viper | NORMAL | 2025-03-28T10:47:43.776385+00:00 | 2025-03-28T10:47:43.776385+00:00 | 1 | false |
# Code
```cpp []
class Solution {
public:
int maximumLength(string s) {
unordered_map <string , int> map;
int len = s.length();
for(int i =0 ; i < len ; i ++ ){
string str ="";
for ( int j = i ; j < len ; j ++ ){
if( !str.empty() && str.back() != s[... | 0 | 0 | ['C++'] | 0 |
find-longest-special-substring-that-occurs-thrice-i | Easy C++ solution using sliding window and hash map | easy-c-solution-using-sliding-window-and-pxuu | Code | imran2018wahid | NORMAL | 2025-03-27T11:25:16.379254+00:00 | 2025-03-27T11:25:16.379254+00:00 | 1 | false | # Code
```cpp []
class Solution {
public:
int maximumLength(string s) {
int ans = 0, j = 0;
string current = "";
unordered_map<string, int> m;
for (int i=0;i<s.length();i++) {
current += s[i];
if (s[i] != s[j]) {
j = i;
current ... | 0 | 0 | ['Sliding Window', 'C++'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.