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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
remove-nth-node-from-end-of-list | Easy ,Beginner Friendly & Dry Run || Simple loops || Time O(N) Space O(1) || Gits ✅✅✅👈👈 | easy-beginner-friendly-dry-run-simple-lo-ea7q | \n\n# Intuition \uD83D\uDC48\n\nIn the given question, you are provided with the head of a linked list and a number n. You are required to remove the nth node f | GiteshSK_12 | NORMAL | 2024-02-07T12:30:04.651212+00:00 | 2024-02-07T12:30:04.651244+00:00 | 1,324 | false | \n\n# Intuition \uD83D\uDC48\n\nIn the given question, you are provided with the head of a linked list and a number n. You are required to remove the nth node from the end of the list... | 7 | 0 | ['Linked List', 'Two Pointers', 'C', 'Python', 'C++', 'Java', 'Python3', 'Ruby', 'JavaScript', 'C#'] | 1 |
remove-nth-node-from-end-of-list | [Python] - Two Pointer - Clean & Simple - O(n) Solution | python-two-pointer-clean-simple-on-solut-9jv1 | \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. O(n) \n\n | yash_visavadia | NORMAL | 2023-02-17T18:51:06.843886+00:00 | 2023-02-17T18:54:00.993802+00:00 | 3,945 | false | \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. $$O(n)$$ -->\n\n# Code\n```\n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.... | 7 | 0 | ['Linked List', 'Two Pointers', 'Python3'] | 1 |
remove-nth-node-from-end-of-list | Javascript very very easy to understand solution with video explanation! | javascript-very-very-easy-to-understand-4iydu | Here is video for explain if it is helpful please subscribe! :\n\n\n\nhttps://youtu.be/yvYtR-KPD6c\n\n# Code\n\n/**\n * Definition for singly-linked list.\n * f | rlawnsqja850 | NORMAL | 2023-01-17T01:51:41.312388+00:00 | 2023-01-17T01:51:41.312415+00:00 | 2,355 | false | Here is video for explain if it is helpful please subscribe! :\n\n\n\nhttps://youtu.be/yvYtR-KPD6c\n\n# Code\n```\n/**\n * Definition for singly-linked list.\n * function ListNode(val, next) {\n * this.val = (val===undefined ? 0 : val)\n * this.next = (next===undefined ? null : next)\n * }\n */\n/**\n * @param ... | 7 | 0 | ['JavaScript'] | 0 |
remove-nth-node-from-end-of-list | [0ms][1LINER][100%][Fastest Solution Explained] O(n)time complexity O(n)space complexity | 0ms1liner100fastest-solution-explained-o-sk0w | (Note: This is part of a series of Leetcode solution explanations. If you like this solution or find it useful, please upvote this post.)\nTake care brother, pe | darian-catalin-cucer | NORMAL | 2022-06-08T17:14:19.112293+00:00 | 2022-06-08T17:14:19.112328+00:00 | 1,678 | false | (Note: This is part of a series of Leetcode solution explanations. If you like this solution or find it useful, ***please upvote*** this post.)\n***Take care brother, peace, love!***\n\n```\n```\n\nThe best result for the code below is ***0ms / 38.2MB*** (beats 92.04% / 24.00%).\n* *** Kotlin ***\n\n```\n\n/**\n * Exam... | 7 | 2 | ['C', 'PHP', 'C++', 'Java', 'Kotlin', 'JavaScript'] | 3 |
remove-nth-node-from-end-of-list | ✔C++ Two Pointer || Easy to Understand || Time O(n) || Space O(1) | c-two-pointer-easy-to-understand-time-on-g6gb | \nPlease Upvote if it helps...!\n\nclass Solution {\npublic:\n ListNode* removeNthFromEnd(ListNode* head, int n) {\n ListNode *slow = head;\n L | iqlipse_abhi | NORMAL | 2022-01-09T10:06:03.254311+00:00 | 2022-01-17T11:12:02.135855+00:00 | 458 | false | \n**Please Upvote if it helps...!**\n```\nclass Solution {\npublic:\n ListNode* removeNthFromEnd(ListNode* head, int n) {\n ListNode *slow = head;\n ListNode *fast = head;\n int count =... | 7 | 1 | ['Two Pointers', 'C'] | 1 |
remove-nth-node-from-end-of-list | Java Solution using Two Pointer and in One Pass | java-solution-using-two-pointer-and-in-o-kum6 | Idea:- For solving this question in one pass we can use two pointer approach. In this approach we make two pointer and maintain a gap of size n-1 between these | rohit_malangi | NORMAL | 2021-09-13T03:00:45.365897+00:00 | 2021-09-13T03:03:16.705983+00:00 | 848 | false | Idea:- For solving this question in one pass we can use two pointer approach. In this approach we make two pointer and maintain a gap of size n-1 between these two pointers. \nWhen first pointer is at the end of the list we sure that second pointer at n+1 position from end . Now we need only remove nth element with the... | 7 | 0 | ['Two Pointers', 'Java'] | 0 |
remove-nth-node-from-end-of-list | 0ms, 2.3mb - Readable code | 0ms-23mb-readable-code-by-fracasula-r523 | \nfunc removeNthFromEnd(head *ListNode, n int) *ListNode {\n\tdummy := &ListNode{Next: head}\n\t// the 2nd pointer will advance only after \n\t// we processed t | fracasula | NORMAL | 2021-08-29T08:38:23.375942+00:00 | 2021-08-29T08:38:23.375972+00:00 | 453 | false | ```\nfunc removeNthFromEnd(head *ListNode, n int) *ListNode {\n\tdummy := &ListNode{Next: head}\n\t// the 2nd pointer will advance only after \n\t// we processed the first n nodes\n\tfirst, second := dummy, dummy\n\n\tvar count int\n\tfor first.Next != nil {\n\t\tfirst = first.Next\n\t\t\n\t\tcount++\n\t\tif count > n ... | 7 | 0 | ['Go'] | 2 |
remove-nth-node-from-end-of-list | simple one pass solution in java | explained | 0ms faster than 100% | simple-one-pass-solution-in-java-explain-mu5h | ```\nclass Solution {\n public ListNode removeNthFromEnd(ListNode head, int n) {\n // Create two nodes pointing to head;\n var first = head;\n | MrAlpha786 | NORMAL | 2021-08-01T15:21:23.387389+00:00 | 2021-08-01T15:21:23.387445+00:00 | 545 | false | ```\nclass Solution {\n public ListNode removeNthFromEnd(ListNode head, int n) {\n // Create two nodes pointing to head;\n var first = head;\n var second = head;\n \n // make second node n nodes ahead of first node;\n for (int i =0; i <n; i++)\n second = second.ne... | 7 | 0 | ['Java'] | 1 |
remove-nth-node-from-end-of-list | Clean c solution | clean-c-solution-by-tim37021-n5wn | c\nstruct ListNode* removeNthFromEnd(struct ListNode* head, int n){\n struct ListNode *p=head, *q=head;\n\t// delay by n nodes.\n for(int i=0; i<n; i++) { | tim37021 | NORMAL | 2020-11-04T06:59:18.717583+00:00 | 2020-11-04T06:59:18.717654+00:00 | 622 | false | ```c\nstruct ListNode* removeNthFromEnd(struct ListNode* head, int n){\n struct ListNode *p=head, *q=head;\n\t// delay by n nodes.\n for(int i=0; i<n; i++) {\n p = p->next;\n }\n if(!p) {\n //remove head\n return head->next;\n }\n\t// pass through\n while(p->next) {\n p = p... | 7 | 0 | [] | 2 |
remove-nth-node-from-end-of-list | Two Pointers: farer than 99.67% memory less than 99.98% | two-pointers-farer-than-9967-memory-less-1597 | \nclass Solution:\n def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:\n fast = head\n while n > 0:\n fast = fast.next\ | dqdwsdlws | NORMAL | 2020-10-28T05:18:55.516007+00:00 | 2020-10-28T11:00:46.979140+00:00 | 708 | false | ```\nclass Solution:\n def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:\n fast = head\n while n > 0:\n fast = fast.next\n n -= 1\n if not fast: return head.next\n slow = head\n while fast.next:\n fast = fast.next\n slow = s... | 7 | 0 | ['Python', 'Python3'] | 2 |
remove-nth-node-from-end-of-list | Unsafe rust single pass solution | unsafe-rust-single-pass-solution-by-lkrb-2kpm | The fastest solution is to use two pointers, one in front and the other n step back. When the front pointer hits the end of the list, the tail pointer points at | lkrb | NORMAL | 2019-05-08T17:58:46.450092+00:00 | 2019-05-08T17:58:46.450156+00:00 | 492 | false | The fastest solution is to use two pointers, one in front and the other n step back. When the front pointer hits the end of the list, the tail pointer points at the node to remove. So the front pointer can be immutable while the tail one must be mutable. \n\nHowever, we cannot have both an immutable and a mutable refer... | 7 | 0 | [] | 0 |
remove-nth-node-from-end-of-list | Python One Pass | python-one-pass-by-wangqiuc-x31r | Suppose the length of linked list is L, the distance between the node to delete and the tail is |node-tail| = N. Then |node-head| = L-N. So we can use two point | wangqiuc | NORMAL | 2019-03-02T21:08:17.176246+00:00 | 2019-03-02T21:08:17.176296+00:00 | 951 | false | Suppose the length of linked list is L, the distance between the node to delete and the tail is **|node-tail| = N**. Then **|node-head| = L-N**. So we can use two pointers here to get that **L-N**.\n\nPointer **a** first walks N units and there are L-N units left that **a** can walk. Then we have **b** start walking fr... | 7 | 0 | [] | 3 |
remove-nth-node-from-end-of-list | Rust 0 ms solution | rust-0-ms-solution-by-aleihanami-opwm | rust\nimpl Solution {\n pub fn remove_nth_from_end(head: Option<Box<ListNode>>, n: i32) -> Option<Box<ListNode>> {\n let mut dummy_head = Some(Box::ne | aleihanami | NORMAL | 2019-01-17T15:50:54.753577+00:00 | 2019-01-17T15:50:54.753643+00:00 | 702 | false | ```rust\nimpl Solution {\n pub fn remove_nth_from_end(head: Option<Box<ListNode>>, n: i32) -> Option<Box<ListNode>> {\n let mut dummy_head = Some(Box::new(ListNode {\n val: 0, next: head,\n }));\n let mut len = 0;\n {\n let mut p = dummy_head.as_ref();\n w... | 7 | 0 | [] | 1 |
longest-substring-of-all-vowels-in-order | Best C++ Solution | best-c-solution-by-6cdh-utju | The basic idea is \'a\' < \'e\' < \'i\' < \'o\' < \'u\'. So this problem is to find the length of the longest non-decreasing substring that has five different c | 6cdh | NORMAL | 2021-04-25T04:25:45.735335+00:00 | 2021-04-25T04:25:45.735409+00:00 | 6,671 | false | The basic idea is `\'a\' < \'e\' < \'i\' < \'o\' < \'u\'`. So this problem is to find the length of the longest non-decreasing substring that has five different chars.\n\n```c++\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n const auto n = word.size();\n\n int cnt = 1;\n ... | 217 | 1 | ['C'] | 21 |
longest-substring-of-all-vowels-in-order | [Java/Python 3] Sliding window codes, w/ brief explanation and analysis. | javapython-3-sliding-window-codes-w-brie-ledd | Loop through input string and maintain a sliding window to fit in beautiful substrings;\n2. Use a Set seen to check the number of distinct vowels in the sliding | rock | NORMAL | 2021-04-25T04:12:34.337466+00:00 | 2021-04-25T18:22:01.277011+00:00 | 4,927 | false | 1. Loop through input string and maintain a sliding window to fit in beautiful substrings;\n2. Use a Set `seen` to check the number of distinct vowels in the sliding window;\n3. Whenever adjacent letters is not in alpahbetic order, start a new window and new Set;\n4. For each iteration of the loop, add the correponding... | 58 | 0 | [] | 8 |
longest-substring-of-all-vowels-in-order | Java Simple | java-simple-by-vikrant_pc-00x8 | \npublic int longestBeautifulSubstring(String word) {\n\tint result = 0, currentLength = 0, vowelCount = 0;\n\tfor(int i=0;i<word.length();i++) {\n\t\tif(i!=0 & | vikrant_pc | NORMAL | 2021-04-25T04:01:40.241758+00:00 | 2021-04-30T04:45:08.238400+00:00 | 2,273 | false | ```\npublic int longestBeautifulSubstring(String word) {\n\tint result = 0, currentLength = 0, vowelCount = 0;\n\tfor(int i=0;i<word.length();i++) {\n\t\tif(i!=0 && word.charAt(i) < word.charAt(i-1)) {\n\t\t\tvowelCount = 0;\n\t\t\tcurrentLength = 0;\n\t\t}\n\t\tcurrentLength++;\n\t\tif(i==0 || word.charAt(i) != word.c... | 36 | 3 | [] | 6 |
longest-substring-of-all-vowels-in-order | JAVA READABLE CODE || Constant Space | java-readable-code-constant-space-by-him-eip2 | Idea:\n Given word only contains vowels(given in question) and we just have to find out the longest substring that contains all vowels in sorted order of ascii | himanshuchhikara | NORMAL | 2021-04-25T10:13:17.836288+00:00 | 2021-04-30T12:44:01.065666+00:00 | 1,791 | false | **Idea:**\n Given word only contains vowels(given in question) and we just have to find out the longest substring that contains all vowels in sorted order of ascii value. i.e \'a\'<\'e\'<\'i\'<\'o\'<\'u\' .\n So if a substring have 5 unique character and following ascii order we can update our answer by its length.\n**... | 28 | 1 | ['Java'] | 4 |
longest-substring-of-all-vowels-in-order | C++ O(n) | c-on-by-votrubac-4evh | cpp\nint longestBeautifulSubstring(string w) {\n int res = 0;\n for (int i = 0, j = 0; i < w.size(); ++i) {\n if (w[i] == \'a\') {\n int | votrubac | NORMAL | 2021-04-25T04:20:45.906032+00:00 | 2021-04-25T06:58:20.087431+00:00 | 2,387 | false | ```cpp\nint longestBeautifulSubstring(string w) {\n int res = 0;\n for (int i = 0, j = 0; i < w.size(); ++i) {\n if (w[i] == \'a\') {\n int cnt = 0;\n for (j = i + 1; j < w.size() && w[j - 1] <= w[j]; ++j)\n cnt += w[j - 1] < w[j];\n if (cnt == 4)\n ... | 27 | 2 | [] | 3 |
longest-substring-of-all-vowels-in-order | Just 7 lines of code || Easiest Solution | just-7-lines-of-code-easiest-solution-by-5xb4 | Approach\n Describe your approach to solving the problem. \nTwo Pointer Approach: \n\n count variable is looking for the all vowels in current substring window. | ha_vi_ag- | NORMAL | 2023-02-06T06:47:41.444219+00:00 | 2023-02-06T06:47:41.444246+00:00 | 1,054 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n**Two Pointer Approach**: \n\n* **count** variable is looking for the all vowels in current substring window.\n* The idea behind **count** variable is, it counts all the **"<"** operations. if it equals 5 it implies we got all the vowels.\n* if sorted... | 18 | 0 | ['Sliding Window', 'C++'] | 1 |
longest-substring-of-all-vowels-in-order | [Python3] greedy | python3-greedy-by-ye15-auyj | \n\nclass Solution:\n def longestBeautifulSubstring(self, word: str) -> int:\n vowels = "aeiou"\n ans = 0\n cnt = prev = -1 \n fo | ye15 | NORMAL | 2021-04-25T04:01:33.584725+00:00 | 2021-04-25T16:04:49.642098+00:00 | 1,734 | false | \n```\nclass Solution:\n def longestBeautifulSubstring(self, word: str) -> int:\n vowels = "aeiou"\n ans = 0\n cnt = prev = -1 \n for i, x in enumerate(word): \n curr = vowels.index(x)\n if cnt >= 0: # in the middle of counting \n if 0 <= curr - prev <... | 11 | 0 | ['Python3'] | 2 |
longest-substring-of-all-vowels-in-order | C++ Solution using Stack | c-solution-using-stack-by-krishnam1998gk-o3fd | Below is the solution using stack. I will explain each and every step of my logic\n1. It is obvious that if the length of the string is smaller than 5 the answe | krishnam1998gkp | NORMAL | 2021-04-25T04:42:24.027698+00:00 | 2021-04-25T04:42:24.027730+00:00 | 566 | false | Below is the solution using stack. I will explain each and every step of my logic\n1. It is obvious that if the length of the string is smaller than **5** the answer is **0**.\n2. Initialising all the variables and stack of characters\n```\n\tstack<char> st;\n\tint i=0,j=0,count=0,ans=INT_MIN,f=0;\n```\n3.We run a whil... | 10 | 1 | [] | 5 |
longest-substring-of-all-vowels-in-order | Simple solution || Easy to understand || Explained !! | simple-solution-easy-to-understand-expla-ah03 | The idea is simple,we use two pointers to find the length of longest substring.\nInitially i=0,j=1;\n-> whenever we find word[j]<word[j-1], we check whether all | srinivasteja18 | NORMAL | 2021-04-25T04:27:48.752597+00:00 | 2021-04-25T04:27:48.752634+00:00 | 727 | false | The idea is simple,we use two pointers to find the length of longest substring.\nInitially i=0,j=1;\n-> whenever we find `word[j]<word[j-1]`, we check whether all chars in `"aeiou`" present in substring `j-i`, we use map to find that.\n-> If ` m.size() ==5` then we update the `maxi` which is longest substring and updat... | 10 | 1 | ['C'] | 0 |
longest-substring-of-all-vowels-in-order | [Python3] 98% Fast Solution | python3-98-fast-solution-by-voidcupboard-b9dk | \nfrom itertools import groupby\n\nclass Solution:\n def longestBeautifulSubstring(self, word: str) -> int:\n arr = groupby(word)\n \n a | VoidCupboard | NORMAL | 2021-05-28T13:39:38.533622+00:00 | 2021-05-28T13:39:38.533667+00:00 | 1,235 | false | ```\nfrom itertools import groupby\n\nclass Solution:\n def longestBeautifulSubstring(self, word: str) -> int:\n arr = groupby(word)\n \n ans = []\n \n count = 0\n \n for i , j in arr:\n ans.append([i , list(j)])\n \n for i in range(le... | 9 | 0 | ['Python3'] | 0 |
longest-substring-of-all-vowels-in-order | Easy understanding | Brute Force | No extra space | Simple c++ | easy-understanding-brute-force-no-extra-51mo9 | C++ solution:\n\nclass Solution {\npublic:\n \n int longestBeautifulSubstring(string s) {\n int n=s.size();\n int ans=0;\n for(int i= | millenniumdart09 | NORMAL | 2021-04-25T04:12:17.964250+00:00 | 2021-04-25T04:30:47.777746+00:00 | 552 | false | **C++ solution:**\n```\nclass Solution {\npublic:\n \n int longestBeautifulSubstring(string s) {\n int n=s.size();\n int ans=0;\n for(int i=0;i<n;)\n {\n if(s[i]==\'a\')\n {\n int c=1;\n int count=0;\n while(i<n&&s[i]==... | 7 | 3 | ['C'] | 2 |
longest-substring-of-all-vowels-in-order | C++ | Easy to understand | Time Complexity - O(N) | Space Complexity - O(1) | c-easy-to-understand-time-complexity-on-cdfum | \nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n int n = word.length();\n \n int i = 0;\n int ans = | CPP_Bot | NORMAL | 2022-08-11T19:06:54.583240+00:00 | 2022-08-11T19:06:54.583267+00:00 | 596 | false | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n int n = word.length();\n \n int i = 0;\n int ans = 0;\n \n while(i<n){\n int ac = 0;\n int ec = 0;\n int ic = 0;\n int oc = 0;\n int uc = 0... | 6 | 0 | [] | 2 |
longest-substring-of-all-vowels-in-order | Straightforward Python3 O(n) stack solution with explanations | straightforward-python3-on-stack-solutio-1ebq | \nclass Solution:\n def longestBeautifulSubstring(self, word: str) -> int:\n d = {}\n d[\'a\'] = {\'a\', \'e\'}\n d[\'e\'] = {\'e\', \'i | tkuo-tkuo | NORMAL | 2021-04-25T07:07:34.230066+00:00 | 2021-04-28T13:35:48.432726+00:00 | 848 | false | ```\nclass Solution:\n def longestBeautifulSubstring(self, word: str) -> int:\n d = {}\n d[\'a\'] = {\'a\', \'e\'}\n d[\'e\'] = {\'e\', \'i\'}\n d[\'i\'] = {\'i\', \'o\'}\n d[\'o\'] = {\'o\', \'u\'}\n d[\'u\'] = {\'u\'}\n\t\t\n res, stack = 0, []\n for c in wor... | 6 | 0 | ['Stack', 'Python3'] | 2 |
longest-substring-of-all-vowels-in-order | Java O(n) solution, simple to understand | java-on-solution-simple-to-understand-by-t0we | public int longestBeautifulSubstring(String word) {\n \n int max = 0;\n int count = 1, i = 0, j = 1;\n \n while(j < word.leng | ankit03jangra | NORMAL | 2021-05-24T17:35:26.808268+00:00 | 2021-05-24T17:35:26.808307+00:00 | 400 | false | public int longestBeautifulSubstring(String word) {\n \n int max = 0;\n int count = 1, i = 0, j = 1;\n \n while(j < word.length()){\n \n if(word.charAt(j) < word.charAt(j-1)){\n i = j; \n count = 1;\n }\n \n ... | 5 | 0 | ['Sliding Window', 'Java'] | 1 |
longest-substring-of-all-vowels-in-order | [JAVA] [O(n)] | java-on-by-trevor-akshay-gtlv | ```\nclass Solution {\n public int longestBeautifulSubstring(String word) {\n int max = 0;\n for(int i = 1;i<word.length();i++){\n int temp | trevor-akshay | NORMAL | 2021-04-29T15:32:27.829798+00:00 | 2021-04-29T15:32:27.829828+00:00 | 533 | false | ```\nclass Solution {\n public int longestBeautifulSubstring(String word) {\n int max = 0;\n for(int i = 1;i<word.length();i++){\n int temp = 1;\n Set<Character> verify = new HashSet<>();\n verify.add(word.charAt(i-1));\n while(i < word.length() && word.charAt(i) >= word.cha... | 5 | 0 | ['Java'] | 0 |
longest-substring-of-all-vowels-in-order | [Java] Straight Forward Intuitive Solution -explained | java-straight-forward-intuitive-solution-oh59 | \nclass Solution {\n public int longestBeautifulSubstring(String word) {\n int result = 0; \n int start = 0;\n int n = word.length();\n | vinsinin | NORMAL | 2021-04-25T04:24:05.613195+00:00 | 2021-04-25T19:13:45.920648+00:00 | 539 | false | ```\nclass Solution {\n public int longestBeautifulSubstring(String word) {\n int result = 0; \n int start = 0;\n int n = word.length();\n String vowels = "aeiou";\n int v = vowels.length();\n \n if (n < v) return 0; //if the word length is less than that of the act... | 5 | 0 | ['Java'] | 1 |
longest-substring-of-all-vowels-in-order | simple and easy C++ solution 😍❤️🔥 | simple-and-easy-c-solution-by-shishirrsi-1lzf | if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code\n\nclass Solution {\npublic:\n int longestBeautifulSubstring(string s) \n {\n string | shishirRsiam | NORMAL | 2024-06-15T06:28:13.410802+00:00 | 2024-06-15T06:28:13.410830+00:00 | 440 | false | # if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code\n```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string s) \n {\n string need = "aeiou";\n int ans = 0, n = s.size();\n int i = 0, j = 0, cur = 0;\n while(j<n)\n {\n if(s[j] == need[cur])\... | 4 | 0 | ['String', 'Greedy', 'Sliding Window', 'C++'] | 3 |
longest-substring-of-all-vowels-in-order | 70 ms Runtime Solution - C++ | 70-ms-runtime-solution-c-by-day_tripper-4jg4 | \nclass Solution {\npublic:\n int longestBeautifulSubstring(string w) {\n int res = 0, j = 0;\n for (int i = 0; i < w.size(); ++i) {\n if (w[i] = | Day_Tripper | NORMAL | 2022-08-29T17:58:50.938399+00:00 | 2022-08-29T17:58:50.938461+00:00 | 512 | false | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string w) {\n int res = 0, j = 0;\n for (int i = 0; i < w.size(); ++i) {\n if (w[i] == \'a\') {\n int cnt = 0;\n for (j = i + 1; j < w.size() && w[j - 1] <= w[j]; ++j)\n cnt += w[j - 1] < w[j];\n ... | 4 | 0 | ['String'] | 0 |
longest-substring-of-all-vowels-in-order | Avoiding Regular Expression (Regex) Worst Case | avoiding-regular-expression-regex-worst-om01e | The "obvious" regular-expression-based solution for this problem (a+e+i+o+u+) will have quadratic performance on a string of all "a"s.\n\nThis is due to the beh | user9084vW | NORMAL | 2021-09-15T22:47:38.444733+00:00 | 2021-09-15T22:47:38.444764+00:00 | 197 | false | The "obvious" regular-expression-based solution for this problem (`a+e+i+o+u+`) will have quadratic performance on a string of all "a"s.\n\nThis is due to the behavior of regular expression matchers. It will start at the first character, attempt to make a match, and scan to the end of the string to discover that no mat... | 4 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | Easy C++ Single Pass Approach | easy-c-single-pass-approach-by-piyushbis-iwy5 | We are going to store last vowel occured,number of unique vowels,the global max for string length, and local max for string length.\nAt each iteration we will c | piyushbisht3 | NORMAL | 2021-07-25T07:06:47.757514+00:00 | 2021-07-25T07:06:47.757542+00:00 | 430 | false | We are going to store **last vowel occured,number of unique vowels,the global max for string length, and local max for string length.**\nAt each iteration we will check for three cases:\n1. Is incoming vowel equal to the previous vowel stored\n\t* We just increment the local max length of the string. \n\n2. if incoming... | 4 | 0 | ['C'] | 1 |
longest-substring-of-all-vowels-in-order | C++ | (Two pointers) | (Simple and elegant) | c-two-pointers-simple-and-elegant-by-gee-oma0 | PLz do upvote if you find it helpful!!!!\nMaintain two pointers left and right and a map.\nNow we will move on to the right freely,also put elements into the ma | GeekyBits | NORMAL | 2021-05-17T13:02:23.294069+00:00 | 2022-02-17T08:20:33.560883+00:00 | 166 | false | PLz do upvote if you find it helpful!!!!\nMaintain two pointers left and right and a map.\nNow we will move on to the right freely,also put elements into the map as we move on the way until: we find a vowel which precedes the previous letter in the alphabet.\nIf that happens we will check the map size first,if its 5 we... | 4 | 1 | [] | 0 |
longest-substring-of-all-vowels-in-order | A few solutions | a-few-solutions-by-claytonjwong-z1rx | Kotlin\n\nclass Solution {\n fun longestBeautifulSubstring(s: String): Int {\n var best = 0\n var last = \'x\'\n var start = 0\n | claytonjwong | NORMAL | 2021-04-25T04:01:55.817092+00:00 | 2021-04-25T04:52:15.597180+00:00 | 281 | false | *Kotlin*\n```\nclass Solution {\n fun longestBeautifulSubstring(s: String): Int {\n var best = 0\n var last = \'x\'\n var start = 0\n var seen = mutableSetOf<Char>()\n for (i in 0 until s.length) {\n if (s[i] < last) { // \uD83D\uDEAB violation to l... | 4 | 0 | [] | 1 |
longest-substring-of-all-vowels-in-order | ❇ longest-substring-of-all-vowels-in-order👌 🏆O(N)❤️ Javascript🎯 Memory👀95.45%🕕 ++Explanation✍️ | longest-substring-of-all-vowels-in-order-x6d7 | \n\nTime Complexity: O(N)\nSpace Complexity: O(1)\n\n\nvar longestBeautifulSubstring = function (word) {\n const pattern = [\'a\', \'e\', \'i\', \'o\', \'u\' | anurag-sindhu | NORMAL | 2024-05-18T17:36:16.674693+00:00 | 2024-05-18T17:37:43.868971+00:00 | 110 | false | \n\nTime Complexity: O(N)\nSpace Complexity: O(1)\n\n```\nvar longestBeautifulSubstring = function (word) {\n const pattern = [\'a\', \'e\', \'i\', \'o\', \'u\'];\n let patternIndex = 0;\n let output =... | 3 | 0 | ['JavaScript'] | 0 |
longest-substring-of-all-vowels-in-order | C++✅✅ | Faster🚀 than 90%🔥| A TRICK TO HANDLE ORDERING👌| Sliding Window🆗 | | c-faster-than-90-a-trick-to-handle-order-oxmt | \n\n# Code\n\n\nclass Solution {\npublic:\n\n int longestBeautifulSubstring(string w) {\n \n int n = w.size();\n vector<pair<char,int>>vp;\n | mr_kamran | NORMAL | 2023-04-01T08:58:26.805460+00:00 | 2023-04-01T08:58:26.805492+00:00 | 1,160 | false | \n\n# Code\n```\n\nclass Solution {\npublic:\n\n int longestBeautifulSubstring(string w) {\n \n int n = w.size();\n vector<pair<char,int>>vp;\n char curr = w[0];\n int cnt = 0;\n for(int i = 0;i<n;)\n {\n while(w[i]==curr && i < n)\n {\n i++; cnt++;\n ... | 3 | 0 | ['C++'] | 0 |
longest-substring-of-all-vowels-in-order | C++ easy to understand | c-easy-to-understand-by-batsy01-5ljy | \nclass Solution {\npublic:\n \n int longestBeautifulSubstring(string word) {\n //longest beautiful substring\n //next character should be e | batsy01 | NORMAL | 2022-01-09T06:18:46.388868+00:00 | 2022-01-09T06:18:46.388917+00:00 | 135 | false | ```\nclass Solution {\npublic:\n \n int longestBeautifulSubstring(string word) {\n //longest beautiful substring\n //next character should be equal of greater than the prevoius one\n //if fails -> start new window\n //each of english vowel must appear at once i.e. mp.size()==5\n ... | 3 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | ✅ [C++] (Sliding Window) Solution for 1839. Longest Substring Of All Vowels in Order | c-sliding-window-solution-for-1839-longe-k0qo | null | utcarsh | NORMAL | 2021-11-08T03:39:19.055665+00:00 | 2021-11-08T06:18:16.788785+00:00 | 424 | false | <iframe src="https://leetcode.com/playground/m92efik6/shared" frameBorder="0" width="800" height="400"></iframe> | 3 | 0 | ['C', 'Sliding Window', 'C++'] | 0 |
longest-substring-of-all-vowels-in-order | C++ || without Sliding window || Map | c-without-sliding-window-map-by-priyanka-kdh8 | \n\npublic:\n int longestBeautifulSubstring(string s) {\n long long int i,j,m=0;\n for(j=0;j<s.length();j++)\n {\n if(s[j]==\ | priyanka1230 | NORMAL | 2021-08-17T15:34:29.334364+00:00 | 2021-08-17T15:34:29.334403+00:00 | 158 | false | ```\n\n```public:\n int longestBeautifulSubstring(string s) {\n long long int i,j,m=0;\n for(j=0;j<s.length();j++)\n {\n if(s[j]==\'a\')\n {\n i=j;\n map<int,int>mp;\n while(i<s.length()&&s[i]==\'a\')\n {\n ... | 3 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | Java solution | java-solution-by-rkxyiiyk2-1vo3 | \nclass Solution {\n public int longestBeautifulSubstring(String word) {\n \n int maxCount = 0, currCount = 1, vowCount = 1;\n \n | rkxyiiyk2 | NORMAL | 2021-07-23T03:21:13.401373+00:00 | 2021-07-23T03:23:17.154309+00:00 | 292 | false | ```\nclass Solution {\n public int longestBeautifulSubstring(String word) {\n \n int maxCount = 0, currCount = 1, vowCount = 1;\n \n for (int i = 1; i < word.length(); i++) {\n char prev = word.charAt(i-1);\n char curr = word.charAt(i);\n if (curr < prev) ... | 3 | 0 | ['Java'] | 0 |
longest-substring-of-all-vowels-in-order | Python3 simple solution using two pointer approach | python3-simple-solution-using-two-pointe-bzsl | \nclass Solution:\n def longestBeautifulSubstring(self, s: str) -> int:\n i,j,x = 0,0,0\n while j < len(s):\n if s[j] in [\'a\', \'e | EklavyaJoshi | NORMAL | 2021-05-07T17:43:33.318349+00:00 | 2021-05-07T17:43:33.318394+00:00 | 247 | false | ```\nclass Solution:\n def longestBeautifulSubstring(self, s: str) -> int:\n i,j,x = 0,0,0\n while j < len(s):\n if s[j] in [\'a\', \'e\', \'i\', \'o\', \'u\'] and (s[j-1] <= s[j] or j == 0):\n j += 1\n else:\n if len(set(s[i:j])) == 5:\n ... | 3 | 0 | ['Two Pointers', 'Python3'] | 1 |
longest-substring-of-all-vowels-in-order | Python solution | Lengthy but beginner friendly | python-solution-lengthy-but-beginner-fri-5v3o | \nclass Solution:\n def longestBeautifulSubstring(self, word: str) -> int:\n mx=0\n ans=0\n res=""\n endcaseans=""\n v="ae | rohansk | NORMAL | 2021-04-25T10:09:41.274513+00:00 | 2021-05-15T05:29:50.036360+00:00 | 86 | false | ```\nclass Solution:\n def longestBeautifulSubstring(self, word: str) -> int:\n mx=0\n ans=0\n res=""\n endcaseans=""\n v="aeiou"\n for i in range(0,len(word)-1):\n if word[i]<=word[i+1]:\n res+=word[i]\n else:\n res+=word[... | 3 | 1 | [] | 0 |
longest-substring-of-all-vowels-in-order | Sliding window with multiple conditions java | sliding-window-with-multiple-conditions-l88mf | Sliding window with multiple conditions, if you can optimize thise code, please add the comment.\n\nclass Solution {\n public int longestBeautifulSubstring(S | karthik1239 | NORMAL | 2021-04-25T04:37:00.281347+00:00 | 2021-04-25T04:42:30.631472+00:00 | 229 | false | Sliding window with multiple conditions, if you can optimize thise code, please add the comment.\n```\nclass Solution {\n public int longestBeautifulSubstring(String word) {\n int max = 0;\n int start = 0;\n int end = 0;\n int len = word.length();\n char[] vowels = {\'a\', \'e\', \... | 3 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | C++ slinding window solution very easy | c-slinding-window-solution-very-easy-by-ruae4 | \nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n int ans=0;\n for (int i=0;i<word.size();)\n {\n | rkrrathorerohit10 | NORMAL | 2021-04-25T04:04:45.617835+00:00 | 2021-04-25T04:32:51.053238+00:00 | 195 | false | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n int ans=0;\n for (int i=0;i<word.size();)\n {\n int j=i;\n\t\t\t// we have flag variables for each vowel so that we can know that we have got each vowel in order.\n bool flaga=false,flage=false,... | 3 | 1 | [] | 0 |
longest-substring-of-all-vowels-in-order | C++ solution easy [ reduce to longest increasing substring ] | c-solution-easy-reduce-to-longest-increa-vsf9 | intuition\n\nthis problem can be reduced down to longest increasing substring [ which was not obvious at first atleast for me ]bcz i was trying sliding window m | zerojude | NORMAL | 2021-04-25T04:01:17.548003+00:00 | 2021-04-25T04:19:09.213760+00:00 | 318 | false | **intuition**\n\nthis problem can be reduced down to longest increasing substring `[ which was not obvious at first atleast for me ] `bcz i was trying sliding window most of time with char string getting wrong ans on edge cases\n\n\n**implementation**\n\nin the first part of code i changed the string to numbers that wa... | 3 | 3 | ['Sliding Window'] | 0 |
longest-substring-of-all-vowels-in-order | Longest Beautiful Substring | C++ Solution | Two Pointer + Greedy | O(N) Time | longest-beautiful-substring-c-solution-t-pzz2 | IntuitionWe’re asked to find the length of the longest "beautiful" substring—a substring that:
Contains all 5 vowels: 'a', 'e', 'i', 'o', 'u'
Appears in lexi | Praveenkumaryadav | NORMAL | 2025-04-06T17:31:13.821935+00:00 | 2025-04-06T17:36:49.032421+00:00 | 23 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We’re asked to find the length of the longest "beautiful" substring—a substring that:
- Contains all 5 vowels: 'a', 'e', 'i', 'o', 'u'
- Appears in lexicographical order (i.e., 'a' before 'e', 'e' before 'i', etc.)
Instead of checking al... | 2 | 0 | ['String', 'Sliding Window', 'C++', 'Java'] | 0 |
longest-substring-of-all-vowels-in-order | 🔥EASY JAVA SOLUTION🔥|| READABLE SOLUTION___ | easy-java-solution-readable-solution___-irmnh | Intuition\n Describe your first thoughts on how to solve this problem. \nThe vowels are \'a\',\'e\',\'i\',\'o\',\'u\' So they are in order then only the word be | Baibhab07 | NORMAL | 2024-07-17T03:39:55.024294+00:00 | 2024-07-17T03:39:55.024326+00:00 | 96 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe vowels are `\'a\',\'e\',\'i\',\'o\',\'u\'` So they are in order then only the word become beautiful... which means every word have 5 vowels.\n\n---\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initializ... | 2 | 0 | ['Java'] | 0 |
longest-substring-of-all-vowels-in-order | not a easy python solution, hahaha... | not-a-easy-python-solution-hahaha-by-see-8um6 | 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 | seenumadhavan | NORMAL | 2024-01-28T13:07:59.545630+00:00 | 2024-01-28T13:07:59.545675+00:00 | 307 | 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) : max size of seen and stack can only be si... | 2 | 0 | ['Python3'] | 0 |
longest-substring-of-all-vowels-in-order | ✅💯Very Easy | Simple Solution | very-easy-simple-solution-by-dipesh_12-y36h | 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 | dipesh_12 | NORMAL | 2023-05-06T05:56:12.489499+00:00 | 2023-05-06T05:56:12.489531+00:00 | 631 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 2 | 0 | ['Java'] | 1 |
longest-substring-of-all-vowels-in-order | Java || String Manipulation(Sliding window variation) ✅ | java-string-manipulationsliding-window-v-yumf | \nclass Solution {\n public boolean isDistinct(char a, char b){\n return a!=b;\n }\n public int longestBeautifulSubstring(String word) {\n | Ritabrata_1080 | NORMAL | 2022-10-23T18:30:01.121398+00:00 | 2022-10-23T18:30:01.121444+00:00 | 836 | false | ```\nclass Solution {\n public boolean isDistinct(char a, char b){\n return a!=b;\n }\n public int longestBeautifulSubstring(String word) {\n int maxLen = 0, n = word.length(), count = 1, wordLength = 1;\n for(int i = 1;i<n;i++){\n if(word.charAt(i-1) <= word.charAt(i)){\n ... | 2 | 0 | ['String', 'Sliding Window', 'Java'] | 0 |
longest-substring-of-all-vowels-in-order | ✅Easy Java solution||Without Window Sliding||Beginner Friendly🔥 | easy-java-solutionwithout-window-sliding-ii3b | If you really found my solution helpful please upvote it, as it motivates me to post such kind of codes and help the coding community, if you have some queries | deepVashisth | NORMAL | 2022-09-08T20:04:27.989695+00:00 | 2022-09-08T20:04:27.989739+00:00 | 403 | false | **If you really found my solution helpful please upvote it, as it motivates me to post such kind of codes and help the coding community, if you have some queries or some improvements please feel free to comment and share your views.**\n```\nclass Solution {\n public int longestBeautifulSubstring(String word) {\n ... | 2 | 0 | ['Java'] | 0 |
longest-substring-of-all-vowels-in-order | Most Simple and Easy || Sliding Window || Intuitive || 2 approaches | most-simple-and-easy-sliding-window-intu-zbw2 | Most Intutive:\nGiven word only contains vowels(given in question) and we just have to find out the longest substring that contains all vowels in sorted order o | souravpal4 | NORMAL | 2022-08-30T07:29:55.634800+00:00 | 2022-09-02T04:05:53.843811+00:00 | 75 | false | **Most Intutive:**\nGiven word only contains vowels(given in question) and we just have to find out the longest substring that contains all vowels in sorted order of ascii value. i.e `\'a\'<\'e\'<\'i\'<\'o\'<\'u\' .`\nSo if a substring have 5 unique character and following ascii order we can update our answer by its le... | 2 | 0 | ['Sliding Window', 'Java'] | 0 |
longest-substring-of-all-vowels-in-order | easy sliding window concept || using hashmaps in cpp | easy-sliding-window-concept-using-hashma-cnfh | class Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n vectorA(26,0);\n int j=0 ,i=0;\n int n=word.size();\n | agarwalayush007 | NORMAL | 2022-08-27T14:05:33.209795+00:00 | 2022-08-27T14:05:33.209836+00:00 | 224 | false | class Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n vector<int>A(26,0);\n int j=0 ,i=0;\n int n=word.size();\n \n int count =0,ans=0;\n while(i<n)\n {\n if(i>0 and i!=j and word[i]<word[i-1])\n {\n for(int i=... | 2 | 0 | ['C', 'Sliding Window'] | 0 |
longest-substring-of-all-vowels-in-order | concise solution (faster than 100% typescript submissions) | concise-solution-faster-than-100-typescr-5i8f | Runtime: 99 ms, faster than 100.00% of TypeScript online submissions \n\nfunction longestBeautifulSubstring_2(word: string): number {\n let maxCount = 0\n | cachiengion314 | NORMAL | 2022-04-22T07:51:10.884953+00:00 | 2022-04-22T07:52:20.862968+00:00 | 287 | false | Runtime: 99 ms, faster than 100.00% of TypeScript online submissions \n```\nfunction longestBeautifulSubstring_2(word: string): number {\n let maxCount = 0\n let l = 0, r = 1\n let vowelCount = 1\n\n while (r < word.length) {\n let key_char = word[r]\n if (key_char < word[r - 1]) {\n ... | 2 | 0 | ['TypeScript', 'JavaScript'] | 0 |
longest-substring-of-all-vowels-in-order | JAVA||Sliding window||O(n)||Clear solution | javasliding-windowonclear-solution-by-ch-t5jn | Please upvote if you find it useful! Or leave comments or suggestions below!\nI will try my best to answer them! Thank you!!\n\nclass Solution {\n public int | Changxu_Ren | NORMAL | 2022-01-23T22:56:34.289964+00:00 | 2022-01-23T22:56:34.290018+00:00 | 149 | false | Please upvote if you find it useful! Or leave comments or suggestions below!\nI will try my best to answer them! Thank you!!\n```\nclass Solution {\n public int longestBeautifulSubstring(String word) {\n // the last \'u\' is the sentinel value\n char[] vowels = new char[]{\'a\', \'e\', \'i\', \'o\', \'... | 2 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | C++ | O(n) Simple Solution | c-on-simple-solution-by-getting_on_track-nzj9 | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n vector vowels{\'a\',\'e\',\'i\',\'o\',\'u\'};\n int result = 0; | getting_on_track | NORMAL | 2021-12-21T05:05:27.065374+00:00 | 2021-12-21T05:06:43.641095+00:00 | 105 | false | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n vector<char> vowels{\'a\',\'e\',\'i\',\'o\',\'u\'};\n int result = 0;\n int currPos = 0;\n int runningLength = 0;\n \n for(int i=0;i<word.size();i++)\n {\n if(word[i]==\'a\')\n ... | 2 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | [Python3] Simple single pass | python3-simple-single-pass-by-danwusbu-l2kl | Explanation:\ng holds the unique vowels seen so far, in order.\ncount holds the size of the current substring.\nm holds the max size, and is what we return at t | danwuSBU | NORMAL | 2021-07-16T23:02:40.264155+00:00 | 2021-11-06T01:33:59.843736+00:00 | 272 | false | **Explanation:**\n`g` holds the unique vowels seen so far, in order.\n`count` holds the size of the current substring.\n`m` holds the max size, and is what we return at the end.\n\nWe do one pass through `word`, and if we encounter a vowel, we do one of two things:\n1. If `g` isn\'t empty and `g[-1]` is greater than th... | 2 | 0 | ['Python'] | 1 |
longest-substring-of-all-vowels-in-order | [Java] Clean O(1)-space Solution | java-clean-o1-space-solution-by-xieyun95-zdt3 | \nclass Solution {\n public int longestBeautifulSubstring(String word) {\n int res = 0;\n \n int len = 1; // length of current non-d | xieyun95 | NORMAL | 2021-05-26T03:31:35.730514+00:00 | 2021-05-26T03:31:35.730547+00:00 | 168 | false | ```\nclass Solution {\n public int longestBeautifulSubstring(String word) {\n int res = 0;\n \n int len = 1; // length of current non-decreasing substring\n int count = 1; // number of unique char in current non-decreasing substring\n \n for (int i = 1; i < word.length... | 2 | 0 | ['Java'] | 0 |
longest-substring-of-all-vowels-in-order | [Python] fast and simple | python-fast-and-simple-by-cruim-r1bi | \nclass Solution:\n def longestBeautifulSubstring(self, word: str) -> int:\n begin = None\n best = 0\n a_detected = False\n for i | cruim | NORMAL | 2021-05-21T13:31:01.149055+00:00 | 2021-05-21T13:31:01.149088+00:00 | 360 | false | ```\nclass Solution:\n def longestBeautifulSubstring(self, word: str) -> int:\n begin = None\n best = 0\n a_detected = False\n for index, value in enumerate(word):\n if not a_detected and value == \'a\':\n begin = index\n a_detected = True\n ... | 2 | 0 | ['Python', 'Python3'] | 0 |
longest-substring-of-all-vowels-in-order | Simple c++solution 97% faster | simple-csolution-97-faster-by-ankushjkku-8uan | \tclass Solution {\n\tpublic:\n\t\tint longestBeautifulSubstring(string word) {\n\t\t\tint a=0,e=0,I=0,o=0,u=0; // variables are used to store the frequency se | ankushjkkumar | NORMAL | 2021-05-02T15:20:55.026786+00:00 | 2021-05-02T15:20:55.026827+00:00 | 155 | false | \tclass Solution {\n\tpublic:\n\t\tint longestBeautifulSubstring(string word) {\n\t\t\tint a=0,e=0,I=0,o=0,u=0; // variables are used to store the frequency sequencly\n\t\t\tint n=word.size();\n\t\t\tint maxi=0;\n\t\t\tfor(int i=0;i<word.size();i++)\n\t\t\t{\n\t\t\t\tif(word[i]==\'a\')\n\t\t\t\t{\n\t\t\t\t\t\twhile(i<... | 2 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | Easy C++ Solution O(n) Time and O(1) space | easy-c-solution-on-time-and-o1-space-by-xyrsr | We know a<e<i<o<u . So, here we just need to find the length of longest non-decreasing substring with 5 different characters.\n\nclass Solution {\npublic:\n | akb30 | NORMAL | 2021-04-25T10:23:06.454079+00:00 | 2021-04-25T10:23:06.454106+00:00 | 90 | false | We know a<e<i<o<u . So, here we just need to find the length of longest non-decreasing substring with 5 different characters.\n```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n int j=0;\n int res=0;\n unordered_map<char,int> mp;\n for(int i=0;i<word.size();i+... | 2 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | C++ | Sliding window | with Set | Simple | with comments | c-sliding-window-with-set-simple-with-co-o39k | \nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n \n set<char> checker; //set to store all vowels\n \n | Vlad_III | NORMAL | 2021-04-25T04:51:46.362030+00:00 | 2021-04-25T04:52:33.713326+00:00 | 93 | false | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n \n set<char> checker; //set to store all vowels\n \n int start = 0; \n int end =0;\n int curr =0; \n int ans =0 ; // final answer\n \n while(curr<word.size()){\n ... | 2 | 0 | ['Sliding Window'] | 0 |
longest-substring-of-all-vowels-in-order | [Python] - Bruteforce O(n) - Simple easy to follow solution | python-bruteforce-on-simple-easy-to-foll-g7j8 | Intuition --> \nKeep track of the previous character and it has to be in sequence so the else condition follows accordingly. \n\nTime Complexity:- O(n)\n\n\ncla | ankits0052 | NORMAL | 2021-04-25T04:26:55.760059+00:00 | 2021-04-25T04:28:19.440103+00:00 | 230 | false | Intuition --> \nKeep track of the previous character and it has to be in sequence so the else condition follows accordingly. \n\nTime Complexity:- O(n)\n\n```\nclass Solution:\n def longestBeautifulSubstring(self, word: str) -> int:\n s=0\n prev=\'a\'\n l=[]\n for char in word:\n ... | 2 | 1 | ['Python', 'Python3'] | 0 |
longest-substring-of-all-vowels-in-order | C++ | Solution code | O(n) | 696. Count Binary String | c-solution-code-on-696-count-binary-stri-947m | Concept used here is similar to the solution for the problem 696. Count Binary Substring\n```\nclass Solution {\npublic:\n int longestBeautifulSubstring(stri | ExtraSecond | NORMAL | 2021-04-25T04:03:42.675925+00:00 | 2021-04-25T04:06:15.511454+00:00 | 213 | false | Concept used here is similar to the solution for the problem [696. Count Binary Substring](https://leetcode.com/problems/count-binary-substrings/)\n```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n vector<pair<char,int>> count;\n \n for(int i = 0 ; i < word.size() ;... | 2 | 0 | [] | 1 |
longest-substring-of-all-vowels-in-order | The Quest for the Longest Beautiful Substring: A Vowel Odyssey 🎶🔍 (BEATS 100%) | the-quest-for-the-longest-beautiful-subs-mrc5 | Intuition 🧠💡Alright, let's tackle this problem step by step! Imagine you're on a quest to find the most melodious substring in a string of vowels. The melody mu | Karnsaty | NORMAL | 2025-04-11T07:57:42.226413+00:00 | 2025-04-11T07:57:42.226413+00:00 | 3 | false | # Intuition 🧠💡
Alright, let's tackle this problem step by step! Imagine you're on a quest to find the most melodious substring in a string of vowels. The melody must follow the order 'a', 'e', 'i', 'o', 'u'—like a musical scale going up 🎧. And not just any scale, but one that includes all five vowels in order!
So, ... | 1 | 0 | ['String', 'Sliding Window', 'C++'] | 0 |
longest-substring-of-all-vowels-in-order | C++ | Easy to Understand | Sliding Window | c-easy-to-understand-sliding-window-by-g-8ltb | Intuition
start traversing the string
for every a that you encounter find the max valid window starting from this position
Approach
we initialize two pointers: | ghozt777 | NORMAL | 2025-03-17T20:35:43.320318+00:00 | 2025-03-17T20:36:01.288971+00:00 | 84 | false | # Intuition
- start traversing the string
- for every `a` that you encounter find the max valid window starting from this position
# Approach
- we initialize two pointers: `start` and `end`
- if the current character is `a` then start expanding the window till it becomes invalid -> if we exceed the length or we bre... | 1 | 0 | ['String', 'Sliding Window', 'C++'] | 0 |
longest-substring-of-all-vowels-in-order | Easy Solution using Recursion | easy-solution-using-recursion-by-paidise-nzdx | IntuitionThe problem requires finding the longest substring that contains all five vowels ('a', 'e', 'i', 'o', 'u') in order. The approach involves checking eac | PaidisettySuraj | NORMAL | 2025-03-12T08:28:34.125603+00:00 | 2025-03-12T08:28:34.125603+00:00 | 45 | false | # Intuition
The problem requires finding the longest substring that contains all five vowels ('a', 'e', 'i', 'o', 'u') in order. The approach involves checking each potential starting point of such a substring and verifying if it meets the criteria.
# Approach
Initialization: Define the sequence of vowels and a helper... | 1 | 0 | ['Two Pointers', 'Recursion', 'Sliding Window', 'C++'] | 0 |
longest-substring-of-all-vowels-in-order | My Solution, Beats 96+% | my-solution-beats-96-by-simolekc-q178 | Code | simolekc | NORMAL | 2025-03-10T18:51:22.669216+00:00 | 2025-03-10T18:51:22.669216+00:00 | 83 | false |
# Code
```javascript []
/**
* @param {string} word
* @return {number}
*/
var longestBeautifulSubstring = function (word) {
let n = word.length;
let pntPattern = 0;
const pattern = "aeiou";
let longestBeautiful = 0;
let left = 0;
let right = 0;
while (right < n) {
if (pattern[pn... | 1 | 0 | ['Sliding Window', 'JavaScript'] | 0 |
longest-substring-of-all-vowels-in-order | Easiest c++ solution solve by counting | easiest-c-solution-solve-by-counting-by-c0hsi | IntuitionApproachComplexity
Time complexity: O(n)
Space complexity: O(1)
Code | albert0909 | NORMAL | 2025-03-10T03:35:08.788443+00:00 | 2025-03-10T03:35:08.788443+00:00 | 211 | 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(... | 1 | 0 | ['String', 'Counting', 'C++'] | 0 |
longest-substring-of-all-vowels-in-order | A Greedy Sliding Window Approach | a-greedy-sliding-window-approach-by-rutu-lx69 | Intuition\nThe problem requires finding the longest contiguous substring in which all five vowels (a, e, i, o, u) appear at least once in alphabetical order. Th | RutujaGhadage | NORMAL | 2024-08-10T20:12:12.854269+00:00 | 2024-08-10T20:12:12.854295+00:00 | 287 | false | # Intuition\nThe problem requires finding the longest contiguous substring in which all five vowels (a, e, i, o, u) appear at least once in alphabetical order. The key observation is that as soon as the order is violated, we need to reset the tracking of the current valid substring.\n\n# Approach\n1. Initialization:\n\... | 1 | 0 | ['String', 'Greedy', 'Sliding Window', 'Python3'] | 0 |
longest-substring-of-all-vowels-in-order | Python Intuitive State Machine | python-intuitive-state-machine-by-minecr-7pj4 | Intuition\n Describe your first thoughts on how to solve this problem. \nTrack what state we are in when building the current substring. Then update the maximum | minecraftyugi | NORMAL | 2024-07-09T05:35:50.453983+00:00 | 2024-07-09T05:35:50.454026+00:00 | 18 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTrack what state we are in when building the current substring. Then update the maximum length if our current state matches the conditions for a beautiful substring.\n\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -... | 1 | 0 | ['Python3'] | 0 |
longest-substring-of-all-vowels-in-order | When fresher writes the code XD | O(n) beats 95% | when-fresher-writes-the-code-xd-on-beats-rf13 | Code\n\nclass Solution {\n public int longestBeautifulSubstring(String s) {\n int maxi = 0;\n int startIdx = 0;\n for(int i = 0 ; i < s.length | suryanshnevercodes | NORMAL | 2024-07-05T12:34:12.698830+00:00 | 2024-07-05T12:34:12.698880+00:00 | 69 | false | # Code\n```\nclass Solution {\n public int longestBeautifulSubstring(String s) {\n int maxi = 0;\n int startIdx = 0;\n for(int i = 0 ; i < s.length() - 1 ; i++) {\n boolean aflg = false;\n boolean eflg = false;\n boolean iflg = false;\n boolean oflg = false;\n boolea... | 1 | 0 | ['String', 'Sliding Window', 'Java'] | 0 |
longest-substring-of-all-vowels-in-order | 🔥VERY SIMPLE LOGIC using only vector🔥🔥. Beginner friendly and easy to understand. | very-simple-logic-using-only-vector-begi-13ye | \n# Complexity\n- Time complexity:\n O(n) \n\n- Space complexity:\n O(1) \n\n# Code\n\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) | Saksham_Gulati | NORMAL | 2024-06-19T14:28:45.530530+00:00 | 2024-06-19T14:28:45.530558+00:00 | 206 | false | \n# Complexity\n- Time complexity:\n $$O(n)$$ \n\n- Space complexity:\n $$O(1)$$ \n\n# Code\n```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n int i=0,j=0,n=word.size();\n int mx=0;\n vector<char>v={\'a\',\'e\',\'i\',\'o\',\'u\'};\n while(j<n)\n {\n ... | 1 | 0 | ['Two Pointers', 'Sliding Window', 'C++'] | 0 |
longest-substring-of-all-vowels-in-order | ✅✅Easiest Python Solution | O(n) | Simple linear✅✅no stack/greedy/sliding window/two pointers | easiest-python-solution-on-simple-linear-ywse | Approach\nc is the current counter\nm is the max\np is the pointer on the array a, remembering the current char\n\nIncrement c if the current char is the pointe | nicostoehr | NORMAL | 2024-05-08T21:48:41.126558+00:00 | 2024-05-08T21:48:41.126592+00:00 | 33 | false | # Approach\nc is the current counter\nm is the max\np is the pointer on the array a, remembering the current char\n\nIncrement c if the current char is the pointer char.\nIncrement c and p if the current char is the next pointer char.\nOtherwise make c the new m if the pointer is at the end of the array c is bigger tha... | 1 | 0 | ['Python3'] | 0 |
longest-substring-of-all-vowels-in-order | Fast Java Solution | fast-java-solution-by-seif_hamdy-6dg6 | Intuition\nI will consider the vowels as stages with their alphabetical order and make sure no stages have been skipped and we have passed by all stages to find | Seif_Hamdy | NORMAL | 2024-02-19T08:40:52.115631+00:00 | 2024-02-19T08:40:52.115655+00:00 | 44 | false | # Intuition\nI will consider the vowels as stages with their alphabetical order and make sure no stages have been skipped and we have passed by all stages to find the complete substring\n# Approach\nApproach is described within the comments\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Cod... | 1 | 0 | ['String', 'Sliding Window', 'Java'] | 0 |
longest-substring-of-all-vowels-in-order | Easy understandable sountion in java with o(N) complexity | easy-understandable-sountion-in-java-wit-4tqs | 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 | GantlaRahul | NORMAL | 2024-02-06T07:39:31.762937+00:00 | 2024-02-06T07:39:31.762990+00:00 | 110 | 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 |
longest-substring-of-all-vowels-in-order | simple easy brute force & sliding window | simple-easy-brute-force-sliding-window-b-zcs3 | \n# Complexity\n- Time complexity:\n O(n*n) \n\n- Space complexity:\n O(1) \n \n\n\nclass Solution {\n \n\n public int longestBeautifulSubstring(String wo | indrajeetyadav932001 | NORMAL | 2023-09-07T18:41:22.698340+00:00 | 2023-09-07T18:42:21.074277+00:00 | 137 | false | \n# Complexity\n- Time complexity:\n $$O(n*n)$$ \n\n- Space complexity:\n $$O(1)$$ \n \n```\n\nclass Solution {\n \n\n public int longestBeautifulSubstring(String word) {\n int j=0,ans=0,n=word.length();\n for(int i=0;i<n;i++){\n if(word.charAt(i)==\'a\'){\n int cnt=0;\n ... | 1 | 0 | ['Two Pointers', 'String', 'Sliding Window', 'Java'] | 0 |
longest-substring-of-all-vowels-in-order | Sliding Window Template | C++ | sliding-window-template-c-by-mayanksingh-cvxy | \n\n# Code\n\nclass Solution {\npublic:\n int longestBeautifulSubstring(string nums) {\n int n=nums.size();\n if (n<5) return 0;\n int c | MayankSinghNegi | NORMAL | 2023-05-25T04:39:13.105258+00:00 | 2023-05-25T04:39:13.105311+00:00 | 141 | false | \n\n# Code\n```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string nums) {\n int n=nums.size();\n if (n<5) return 0;\n int count=1,maxi=0;\n set<char> st;\n st.insert(nums[0]);\n for (int i=1;i<n;i++)\n {\n if (nums[i]>=nums[i-1])\n ... | 1 | 0 | ['C++'] | 0 |
longest-substring-of-all-vowels-in-order | Brute Force | brute-force-by-gaurav_sengar-v5uj | 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 | Gaurav_sengar | NORMAL | 2023-03-06T12:50:12.690331+00:00 | 2023-03-06T12:50:12.690367+00:00 | 267 | 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 |
longest-substring-of-all-vowels-in-order | C++ Best Solution||Easy to Understand | c-best-solutioneasy-to-understand-by-ret-rtwh | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string w) \n {\n int len=1,cnt=1,max_len=0;\n for(int i=1;iw[i-1])\n | return_7 | NORMAL | 2022-09-07T18:41:37.494515+00:00 | 2022-09-07T18:41:37.494560+00:00 | 344 | false | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string w) \n {\n int len=1,cnt=1,max_len=0;\n for(int i=1;i<w.size();i++)\n {\n if(w[i]==w[i-1])\n {\n len++;\n }\n else if(w[i]>w[i-1])\n {\n le... | 1 | 0 | ['C'] | 0 |
longest-substring-of-all-vowels-in-order | C++ || Stack || Esay to Understand | c-stack-esay-to-understand-by-himanshu18-gkxh | class Solution {\npublic:\n \n \n int longestBeautifulSubstring(string word) {\n \n int n = word.size();\n stack st;\n unordered_ | Himanshu1802 | NORMAL | 2022-07-20T03:15:32.673205+00:00 | 2022-07-20T03:15:32.673249+00:00 | 36 | false | class Solution {\npublic:\n \n \n int longestBeautifulSubstring(string word) {\n \n int n = word.size();\n stack<char> st;\n unordered_map<char,int> mp;\n int res = 0;\n \n \n for(int i=0; i<n; i++){\n \n char ch = word[i];\n \n... | 1 | 0 | ['Stack', 'C', 'C++'] | 0 |
longest-substring-of-all-vowels-in-order | Easy to understand Explaination | easy-to-understand-explaination-by-sinha-1zfa | \n\nclass Solution {\n public int longestBeautifulSubstring(String word) {\n char[] arr = word.toCharArray();\n int maxLength = 0;\n \n | sinhaneha455 | NORMAL | 2022-07-16T16:50:44.131983+00:00 | 2022-07-16T16:51:50.127039+00:00 | 78 | false | ```\n\nclass Solution {\n public int longestBeautifulSubstring(String word) {\n char[] arr = word.toCharArray();\n int maxLength = 0;\n \n for(int i = 1 ; i < word.length() ; i++){\n if(arr[i-1] == \'a\'){ //we know that our valid window will only start from a , throgh this lin... | 1 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | Nice Question with alot of Brainstorming required || CPP || Moderate || Sliding window | nice-question-with-alot-of-brainstorming-2mpg | \nclass Solution {\npublic:\n int cnt=0;\n bool help(char a,char b){\n if(a==b) return true;\n else if(a==\'a\' && b==\'e\'){\n c | PeeroNappper | NORMAL | 2022-06-16T17:30:54.935660+00:00 | 2022-06-16T17:30:54.935706+00:00 | 261 | false | ```\nclass Solution {\npublic:\n int cnt=0;\n bool help(char a,char b){\n if(a==b) return true;\n else if(a==\'a\' && b==\'e\'){\n cnt++;\n return true;\n }\n else if(a==\'e\' && b==\'i\'){\n cnt++;\n return true;\n }\n else i... | 1 | 0 | ['Sliding Window', 'C++'] | 0 |
longest-substring-of-all-vowels-in-order | Short & clean c++ intuitive code using sliding window & unordered_map | short-clean-c-intuitive-code-using-slidi-tfxj | \nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n unordered_map<char, int> mp;\n int i = 0, ans = 0; \n for(i | yashrajyash | NORMAL | 2022-06-02T16:19:52.953405+00:00 | 2022-06-02T16:19:52.953436+00:00 | 86 | false | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n unordered_map<char, int> mp;\n int i = 0, ans = 0; \n for(int j=0; j<word.length(); j++) {\n if(mp.empty() && word[j] == \'a\') {\n i = j;\n mp[word[j]]++;\n } else... | 1 | 0 | ['Two Pointers', 'C', 'Sliding Window'] | 0 |
longest-substring-of-all-vowels-in-order | JAVA | Lets Bitmask | O(1) space , O(n) time | java-lets-bitmask-o1-space-on-time-by-pr-c3tz | We create a bitmask of all the vowlels i.e a , e , i , o , u.\n2. for every character in word we update the currentMask , where charAt(i) >= charAt(i - 1).\n3. | PrasadDas | NORMAL | 2022-05-12T17:44:27.122269+00:00 | 2022-05-12T17:45:17.916756+00:00 | 106 | false | 1. We create a bitmask of all the vowlels i.e a , e , i , o , u.\n2. for every character in word we update the currentMask , where charAt(i) >= charAt(i - 1).\n3. Where currentMask = originalMask , this could be a possible solution so we update out result\n4. where the order breaks i.e charAt(i) > charAt(i - 1) , we re... | 1 | 0 | ['Bitmask', 'Java'] | 0 |
longest-substring-of-all-vowels-in-order | two pointers | two-pointers-by-ttn628826-2s04 | cpp\n// use this to simplify the comparison between vowels\nmap<char, int> idx = {\n\t{\'a\', 0}, \n\t{\'e\', 1},\n\t{\'i\', 2},\n\t{\'o\', 3},\n\t{\'u\', 4}\n} | ttn628826 | NORMAL | 2022-05-08T10:33:50.738613+00:00 | 2022-05-08T11:01:34.545250+00:00 | 201 | false | ```cpp\n// use this to simplify the comparison between vowels\nmap<char, int> idx = {\n\t{\'a\', 0}, \n\t{\'e\', 1},\n\t{\'i\', 2},\n\t{\'o\', 3},\n\t{\'u\', 4}\n};\n\nint longestBeautifulSubstring(string word) {\n\tint ret = 0;\n\t\n\t// for each char in word,\n\tfor (int i = 0; i < word.size(); ++i)\n\t{\n\t\t// we o... | 1 | 0 | ['Two Pointers', 'C'] | 1 |
longest-substring-of-all-vowels-in-order | C++ || Sliding Window || Time Complexity - O(N) | c-sliding-window-time-complexity-on-by-l-oaer | \nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n int n = word.size(); \n if(n < 5){\n return 0;\n | lcninja_43 | NORMAL | 2022-04-18T09:56:32.522780+00:00 | 2022-04-18T09:56:32.522823+00:00 | 124 | false | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n int n = word.size(); \n if(n < 5){\n return 0;\n }\n unordered_map<char,char> m;\n m[\'a\'] = \'e\', m[\'e\'] = \'i\', m[\'i\'] = \'o\', m[\'o\'] = \'u\';\n int maxlen = 0, i = 0;\n ... | 1 | 0 | ['Sliding Window'] | 0 |
longest-substring-of-all-vowels-in-order | easy to understand c++ solution | easy-to-understand-c-solution-by-ritesh_-4dvw | \n int longestBeautifulSubstring(string word) {\n // please do a dry run on this example "aeiaaioaaaaeiiiiouuuooaauuaeiu"\n// you will understand it better.\n | Ritesh_Mangdare | NORMAL | 2022-04-03T10:09:45.737114+00:00 | 2022-04-03T10:09:45.737155+00:00 | 162 | false | ```\n int longestBeautifulSubstring(string word) {\n // please do a dry run on this example "aeiaaioaaaaeiiiiouuuooaauuaeiu"\n// you will understand it better.\n int i=0,j=0;// two pointers\n int maxlen=0;\n char curr=word[0];// we will use it check that next vowel appeared should be greated than c... | 1 | 0 | ['C', 'Sliding Window', 'C++'] | 0 |
longest-substring-of-all-vowels-in-order | simple Java solution | simple-java-solution-by-sugale85-adfb | \npublic int longestBeautifulSubstring(String word) {\n int cnt = 1;\n int len = 1;\n int max_len = 0;\n for (int i = 1; i != word. | sugale85 | NORMAL | 2022-02-20T12:16:55.843659+00:00 | 2022-02-20T12:17:21.542505+00:00 | 186 | false | ```\npublic int longestBeautifulSubstring(String word) {\n int cnt = 1;\n int len = 1;\n int max_len = 0;\n for (int i = 1; i != word.length(); ++i) {\n if (word.charAt(i - 1) == word.charAt(i)) {\n ++len;\n } else if (word.charAt(i - 1) < word.charAt(i)... | 1 | 0 | ['Java'] | 0 |
longest-substring-of-all-vowels-in-order | C++ short easy to understand , using unordered_set | c-short-easy-to-understand-using-unorder-txk2 | \nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n int ans = 0;\n int start = 0;\n unordered_set<char> set;\n | larryleizhou | NORMAL | 2022-02-18T23:19:01.844732+00:00 | 2022-02-18T23:19:01.844767+00:00 | 81 | false | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word) {\n int ans = 0;\n int start = 0;\n unordered_set<char> set;\n set.insert(word[0]);\n for(int i=1; i<word.size(); ++i) {\n if (word[i]<word[i-1]) { \n start = i;\n ... | 1 | 0 | ['C'] | 0 |
longest-substring-of-all-vowels-in-order | Kotlin Sliding window O(n) | kotlin-sliding-window-on-by-ashabib-czm5 | \n\nfun longestBeautifulSubstring(word: String): Int {\n\t// edge cases\n if (word.length < 5) {\n return 0\n }\n if (word.toList().distinct().s | ashabib | NORMAL | 2022-01-03T12:14:44.522058+00:00 | 2022-01-03T12:14:44.522089+00:00 | 84 | false | ```\n\nfun longestBeautifulSubstring(word: String): Int {\n\t// edge cases\n if (word.length < 5) {\n return 0\n }\n if (word.toList().distinct().size < 5) {\n return 0\n }\n\t\n val characters = word.toCharArray()\n var counter = 1\n var maxValue = 0\n var currentLength = 1\n\t\n ... | 1 | 0 | ['Sliding Window', 'Kotlin'] | 0 |
longest-substring-of-all-vowels-in-order | Python Sliding Window | python-sliding-window-by-pathrise-fellow-6nau | So here is the method of thinking. \nThink brute force first. If you can\'t get the brute force correct you have never understood sliding window. For every ques | pathrise-fellows | NORMAL | 2021-11-22T06:49:18.222421+00:00 | 2021-11-22T06:49:18.222457+00:00 | 98 | false | So here is the method of thinking. \nThink brute force first. If you can\'t get the brute force correct you have never understood sliding window. For every question out there in sliding window no matter how easy/hard it is solve it using brute force even if you know the answer. Understand very clearly in the brute forc... | 1 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | Python Sliding Window Method with Explanation and Extension | python-sliding-window-method-with-explan-ml4i | \nclass Solution:\n def longestBeautifulSubstring(self, word):\n n = len(word)\n length = 0\n order = {"a": 0, "e": 1, "i": 2, "o": 3, " | jinghuayao | NORMAL | 2021-10-16T05:10:19.280568+00:00 | 2021-10-16T06:07:39.987380+00:00 | 93 | false | ```\nclass Solution:\n def longestBeautifulSubstring(self, word):\n n = len(word)\n length = 0\n order = {"a": 0, "e": 1, "i": 2, "o": 3, "u": 4}\n l, r = 0, 0\n while l < n:\n \n # 1. Find the index of "a" after pointer l\n if word[l] != "a":\n ... | 1 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | JAVA || Sliding Window || if -else || easy solution by 2 methods | java-sliding-window-if-else-easy-solutio-g3s2 | \n public int longestBeautifulSubstring(String word) {\n \n int count =1,vowels=1,ans=0;\n \n for(int i=1;i<word.length();i++){\n | ayushx | NORMAL | 2021-07-30T12:30:25.313831+00:00 | 2021-07-30T12:45:59.558955+00:00 | 277 | false | ```\n public int longestBeautifulSubstring(String word) {\n \n int count =1,vowels=1,ans=0;\n \n for(int i=1;i<word.length();i++){\n char cur=word.charAt(i);\n char pre=word.charAt(i-1);\n \n if(pre>cur){\n count=1;\n vowe... | 1 | 0 | ['Sliding Window', 'Java'] | 0 |
longest-substring-of-all-vowels-in-order | c++ Solution || Heavy one | c-solution-heavy-one-by-ngaur6834-yb9v | \tint longestBeautifulSubstring(string word) {\n int n = word.length();\n if(n == 0){\n return 0;\n }\n \n unorder | ngaur6834 | NORMAL | 2021-07-30T06:22:17.973111+00:00 | 2021-07-30T06:22:17.973150+00:00 | 155 | false | \tint longestBeautifulSubstring(string word) {\n int n = word.length();\n if(n == 0){\n return 0;\n }\n \n unordered_map<char, int> mp;\n mp[\'a\'] = 0;\n mp[\'e\'] = 1;\n mp[\'i\'] = 2;\n mp[\'o\'] = 3;\n mp[\'u\'] = 4;\n \n ... | 1 | 0 | ['C'] | 0 |
longest-substring-of-all-vowels-in-order | Java O(n) solution O(1) space, easy to understand. with alternative sliding window solution. | java-on-solution-o1-space-easy-to-unders-5tqt | \nSimple solution \n\nBelow solution runs faster then sliding window.\n\n\n public int longestBeautifulSubstring(String str) {\n char[] vowels = {\'a\ | jayantnarwani | NORMAL | 2021-07-03T06:33:09.028919+00:00 | 2021-07-03T06:40:39.731652+00:00 | 124 | false | \nSimple solution \n\nBelow solution runs faster then sliding window.\n\n```\n public int longestBeautifulSubstring(String str) {\n char[] vowels = {\'a\', \'e\', \'i\', \'o\', \'u\'};\n int count = 0, i =0, max = 0, j = 0;\n \n while (i < str.length()) {\n if (j >= vowels.leng... | 1 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | C++ || Two Pointers || Beats 100% Time and Space | c-two-pointers-beats-100-time-and-space-hr97f | class Solution {\npublic:\n\n int longestBeautifulSubstring(string word) {\n int i=0;\n int j=1;\n int count=1;\n int ans=0;\n | Mohammed_Qubaisuddin | NORMAL | 2021-07-02T09:16:58.590738+00:00 | 2021-07-02T09:16:58.590768+00:00 | 76 | false | class Solution {\npublic:\n\n int longestBeautifulSubstring(string word) {\n int i=0;\n int j=1;\n int count=1;\n int ans=0;\n char ch=word[0];\n while(j<word.length()){\n if(ch==word[j]){\n j++;\n continue;\n }\n ... | 1 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | Simple C++ Solution | simple-c-solution-by-four901-oybi | \nclass Solution {\npublic:\n int longestBeautifulSubstring(string word)\n {\n int maxi=0;\n for(int i=0;i<word.length();)\n {\n | Four901 | NORMAL | 2021-06-14T15:11:40.996938+00:00 | 2021-06-14T15:11:40.996987+00:00 | 78 | false | ```\nclass Solution {\npublic:\n int longestBeautifulSubstring(string word)\n {\n int maxi=0;\n for(int i=0;i<word.length();)\n {\n int a=0,e=0,ii=0,o=0,u=0;\n while(i<word.length())\n {\n if(word[i]!=\'a\')\n {\n ... | 1 | 0 | [] | 0 |
longest-substring-of-all-vowels-in-order | C++ O(n) time , O(1) space | c-on-time-o1-space-by-shubham-khare-xi17 | //keep record of previously appeared all vowels in order.\nclass Solution {\n\npublic:\n int longestBeautifulSubstring(string word) {\n \n int | Shubham-Khare | NORMAL | 2021-06-03T16:40:59.282506+00:00 | 2021-06-03T16:45:44.371986+00:00 | 113 | false | //keep record of previously appeared all vowels in order.\nclass Solution {\n\npublic:\n int longestBeautifulSubstring(string word) {\n \n int ans = 0;\n int count=0;\n int fa=0;\n int fe=0;\n int fo=0;\n int fi=0;\n int fu=0;\n if(word[0]==\'a\') {\n ... | 1 | 0 | [] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.