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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fizz-buzz-multithreaded | C++ atomic | c-atomic-by-wiryls-8nx2 | Use one atomic<int> as a counter.\n\nc++\nstruct FizzBuzz\n{\npublic:\n FizzBuzz(int n)\n : k(1)\n , n(n)\n {}\n\n // printFizz() outputs | wiryls | NORMAL | 2019-09-29T03:19:25.528387+00:00 | 2019-09-29T03:19:25.528436+00:00 | 399 | false | Use one `atomic<int>` as a counter.\n\n```c++\nstruct FizzBuzz\n{\npublic:\n FizzBuzz(int n)\n : k(1)\n , n(n)\n {}\n\n // printFizz() outputs "fizz".\n void fizz(function<void()> output)\n {\n auto outputx = [&](auto i) { output(); };\n output_if(outputx, [](auto i) { return ... | 2 | 0 | ['C'] | 2 |
fizz-buzz-multithreaded | [Java] Basic CyclicBarrier solution - 4ms, 36MB | java-basic-cyclicbarrier-solution-4ms-36-m2am | You process one number at a time. When all 4 threads run together at the same time, only one thing (the same number) will be printed due to the unique if-condit | lk00100100 | NORMAL | 2019-09-22T23:47:22.667313+00:00 | 2020-07-13T13:50:16.095774+00:00 | 246 | false | You process one number at a time. When all 4 threads run together at the same time, only one thing (the same number) will be printed due to the unique if-conditions. All threads must await() before going to the next number. Once all 4 threads have hit await(), the barrier will open thus starting the "process one number... | 2 | 0 | [] | 1 |
fizz-buzz-multithreaded | Python 100% with Event | python-100-with-event-by-ls1229-d8bk | number method control the process, in each thread using cur to record the next value to print, only print while cur<=self.n, if cur%15==0 we need to add 3 or 5 | ls1229 | NORMAL | 2019-09-20T16:00:58.980779+00:00 | 2019-09-20T16:00:58.980830+00:00 | 344 | false | `number` method control the process, in each thread using `cur` to record the next value to print, only print while `cur<=self.n`, if `cur%15==0` we need to add 3 or 5 to the `cur` because the next print is `15` and will jump over 3 or 5.\n```\nfrom threading import Event\nclass FizzBuzz:\n def __init__(self, n: int... | 2 | 0 | [] | 0 |
fizz-buzz-multithreaded | Semaphores | semaphores-by-cds77-zslz | Intuition\nPracticing semaphores\n\n# Approach\nUsing a similar approach for concurrency problems with Semaphores that I figure out the first called method and | cds77 | NORMAL | 2024-10-19T08:11:25.423709+00:00 | 2024-10-19T14:59:24.955212+00:00 | 64 | false | # Intuition\nPracticing semaphores\n\n# Approach\nUsing a similar approach for concurrency problems with Semaphores that I figure out the first called method and block it then based on conditions of the problem I release each lock for a method at a time and then in the released method I block thread - perform whats nee... | 1 | 0 | ['C#'] | 0 |
fizz-buzz-multithreaded | Java - Easy to understand 95% | java-easy-to-understand-95-by-mandyadb1-5cg6 | 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 | mandyadb1 | NORMAL | 2024-08-14T15:33:17.198749+00:00 | 2024-08-14T15:33:17.198778+00:00 | 342 | 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 |
fizz-buzz-multithreaded | [C++] Mutex for each function. Simple to understand solution. | c-mutex-for-each-function-simple-to-unde-b1x3 | Intuition\nEach function has a mutex to prevent unorderly execution. All mutexes are controled via mutexManager() method which tracks the current number and unl | merab_m_ | NORMAL | 2024-07-27T10:39:40.423939+00:00 | 2024-07-27T10:39:40.423976+00:00 | 63 | false | # Intuition\nEach function has a mutex to prevent unorderly execution. All mutexes are controled via `mutexManager()` method which tracks the current number and unlocks respective mutex.\n# Code\n```\nclass FizzBuzz {\nprivate:\n int n;\n\n int nextNumber = 1;\n std::mutex mnum, mfizz, mbuzz, mfizzbuzz;\n\npub... | 1 | 0 | ['C++'] | 0 |
fizz-buzz-multithreaded | Beats 97% Java Users...... | beats-97-java-users-by-aim_high_212-d53r | \n\n# Code\n\nimport java.util.ConcurrentModificationException;\nimport java.util.concurrent.atomic.AtomicInteger;\nimport java.util.function.IntConsumer;\n\ncl | Aim_High_212 | NORMAL | 2024-03-31T08:23:05.546155+00:00 | 2024-03-31T08:23:05.546185+00:00 | 127 | false | \n\n# Code\n```\nimport java.util.ConcurrentModificationException;\nimport java.util.concurrent.atomic.AtomicInteger;\nimport java.util.function.IntConsumer;\n\nclass FizzBuzz {\n\n private final AtomicInteger counter;\n\n private final int n;\n\n public FizzBuzz(int n) {\n this.n = n;\n counter ... | 1 | 0 | ['Java'] | 10 |
fizz-buzz-multithreaded | std:: Conditional Variable Solution | std-conditional-variable-solution-by-ank-cz3w | \n\n# Code\n\nclass FizzBuzz {\nprivate:\n int n;\n mutex m;\n condition_variable c;\n int i;\n\npublic:\n FizzBuzz(int n) {\n \n t | ankush20386 | NORMAL | 2024-03-16T06:37:28.353823+00:00 | 2024-03-16T06:37:28.353850+00:00 | 620 | false | \n\n# Code\n```\nclass FizzBuzz {\nprivate:\n int n;\n mutex m;\n condition_variable c;\n int i;\n\npublic:\n FizzBuzz(int n) {\n \n this->n = n;\n this->i=1;\n }\n\n // printFizz() outputs "fizz".\n void fizz(function<void()> printFizz) {\n while(i<=n)\n {\n ... | 1 | 0 | ['C++'] | 2 |
fizz-buzz-multithreaded | Clean solution with threading.Condition in 22 ms | clean-solution-with-threadingcondition-i-ddo9 | Approach\nIf semaphore (or threading.Event) are used to achieve synchornizaiton, 4 semaphores (or threading.Event) will be needed. 1 condistion variable and not | weii666 | NORMAL | 2024-02-24T14:22:52.443649+00:00 | 2024-02-24T14:25:53.105697+00:00 | 175 | false | # Approach\nIf semaphore (or threading.Event) are used to achieve synchornizaiton, 4 semaphores (or threading.Event) will be needed. 1 condistion variable and notifyAll() are the right mechnisms in this scenario:\n\n- 1 counter, `self.ctr`, is shared by 4 threads\n- for any value of `self.ctr`, there is exactly one thr... | 1 | 0 | ['Python3'] | 0 |
fizz-buzz-multithreaded | Simple solution using wait() and notifyAll() | simple-solution-using-wait-and-notifyall-o53f | 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 | vipin_sharma | NORMAL | 2024-02-07T07:25:49.184085+00:00 | 2024-02-07T07:25:49.184111+00:00 | 203 | 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 |
fizz-buzz-multithreaded | Multithreading w/ spinlocks avoiding mutex/monitor locks; async calculations | multithreading-w-spinlocks-avoiding-mute-8g1g | Code\n\npublic class FizzBuzz\n{\n\n private int _printerIndex = 1;\n private readonly int _n;\n\n public FizzBuzz(int n) {\n _n = n;\n }\n\n | salma2vec | NORMAL | 2023-11-11T09:36:32.361925+00:00 | 2023-11-11T09:36:32.361944+00:00 | 196 | false | # Code\n```\npublic class FizzBuzz\n{\n\n private int _printerIndex = 1;\n private readonly int _n;\n\n public FizzBuzz(int n) {\n _n = n;\n }\n\n private void WaitForPrinterIndexAndIncrement(int i, Action action)\n {\n if (_printerIndex < i)\n System.Threading.SpinWait.SpinUn... | 1 | 0 | ['Concurrency', 'C#'] | 0 |
fizz-buzz-multithreaded | Python very simple solution with semaphores | python-very-simple-solution-with-semapho-bhx6 | Intuition\n Describe your first thoughts on how to solve this problem. \nEach function has its own counter which is incremented by either 1, 3, 5, or 15.\n\nIn | sstef | NORMAL | 2023-10-18T15:16:07.594608+00:00 | 2023-10-18T15:16:07.594633+00:00 | 347 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nEach function has its own counter which is incremented by either 1, 3, 5, or 15.\n\nIn fizz and buzz methods if after increment we get number divisible by both 3 and 5 just increment once again.\n\n# Code\n```\nfrom threading import Semap... | 1 | 0 | ['Python3'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | ✅Easiest 4 Step Cpp / Java / Py / JS Solution | Normal Approach🏆| With Explanation | easiest-4-step-cpp-java-py-js-solution-n-l2yh | 🌟 Step-by-Step Breakdown 🌟1. 🚶 Traverse the Linked List:
Identify critical points (either local minima or maxima).
Use pointers (prev, curr, and next) to compar | dev_yash_ | NORMAL | 2024-07-05T00:48:14.553328+00:00 | 2024-12-17T16:33:18.853846+00:00 | 22,124 | false | ### \uD83C\uDF1F **Step-by-Step Breakdown** \uD83C\uDF1F \n\n**1. \uD83D\uDEB6 Traverse the Linked List:** \nIdentify critical points (either local minima or maxima). \n- Use pointers (`prev`, `curr`, and `next`) to compare the current node\u2019s value with its neighbors. \n- Critical Point: \n - **Peak:** `curr... | 94 | 6 | ['Linked List', 'C', 'Python', 'C++', 'Java', 'Python3', 'JavaScript'] | 15 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | One Pass | one-pass-by-votrubac-7pce | To make it simple, we track:\n- first and last indexes of local min/max.\n- the value of the previous node prev_val.\n- smallest difference between two adjacent | votrubac | NORMAL | 2021-10-31T04:02:07.587764+00:00 | 2021-10-31T04:51:28.218354+00:00 | 8,336 | false | To make it simple, we track:\n- `first` and `last` indexes of local min/max.\n- the value of the previous node `prev_val`.\n- smallest difference between two adjacent indices (current `i` minus `last`) as `min_d`.\n\nThe result is `{min_d, last - first}`.\n\nThe complexity of this solution is *O(n)* time and *O(1)* mem... | 74 | 3 | ['C', 'Java'] | 15 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | [LinkedList Tutorial] Find the Minimum and Maximum Number of Nodes Between Critical Points | linkedlist-tutorial-find-the-minimum-and-p24y | Topic : Linked List\nA linked list is a fundamental data structure in computer science. It consists of nodes where each node contains data and a reference (lin | never_get_piped | NORMAL | 2024-07-05T00:26:15.671080+00:00 | 2024-07-05T05:30:32.192582+00:00 | 9,479 | false | **Topic** : Linked List\nA linked list is a fundamental data structure in computer science. It consists of nodes where each node contains data and a reference (link) to the next node in the sequence. This allows for dynamic memory allocation and efficient insertion and deletion operations compared to arrays. (GFG)\n\n... | 56 | 4 | ['PHP', 'Python', 'Java', 'Go', 'JavaScript'] | 11 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Loop & Linked list||109ms Beats 99.27% | loop-linked-list109ms-beats-9927-by-anwe-oo6r | Intuition\n Describe your first thoughts on how to solve this problem. \nLinked list & find the locations of critical points.\nThen compute min(pos) & max(pos)\ | anwendeng | NORMAL | 2024-07-05T01:41:32.077736+00:00 | 2024-07-05T03:53:58.741172+00:00 | 5,407 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nLinked list & find the locations of critical points.\nThen compute min(pos) & max(pos)\n\n2nd approach is a 1 pass with O(1) space.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Create an array `pos` for holding... | 48 | 3 | ['Linked List', 'C++', 'Python3'] | 9 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | ✅💯🔥Explanations No One Will Give You🎓🧠Detailed Approach🎯🔥Extremely Simple And Effective🔥 | explanations-no-one-will-give-youdetaile-axej | \n \n \n If you don\'t like the road you\'re walking, start paving another one\n \n \n \n | heir-of-god | NORMAL | 2024-07-05T06:25:58.354367+00:00 | 2024-07-05T09:12:31.731898+00:00 | 4,392 | false | <blockquote>\n <p>\n <b>\n If you don\'t like the road you\'re walking, start paving another one\n </b> \n </p>\n <p>\n --- Dolly Parton ---\n </p>\n</blockquote>\n\n# \uD83D\uDC51Problem Explanation and Understanding:\n\n## \uD83C\uDFAF... | 46 | 38 | ['Array', 'Linked List', 'Two Pointers', 'C', 'Python', 'C++', 'Java', 'Python3', 'JavaScript'] | 11 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 🔥🔥Beats 100% | Easy Solution with explanation in java,c++ | beats-100-easy-solution-with-explanation-v0ep | \n\n# Code\njava []\nclass Solution {\n public int[] nodesBetweenCriticalPoints(ListNode head) {\n ListNode prev = head;\n head = head.next;\n | santhosh_kumar_13 | NORMAL | 2024-07-05T03:33:53.037831+00:00 | 2024-07-11T02:01:27.642685+00:00 | 3,282 | false | \n\n# Code\n```java []\nclass Solution {\n public int[] nodesBetweenCriticalPoints(ListNode head) {\n ListNode prev = head;\n head = head.next;\n int i = 1, mindist = Integer.MAX_VALUE, prev_i = Integer.MIN_VALUE, first_i = -1;\n while (head.next != null) {\n if ((prev.val < he... | 39 | 2 | ['C++', 'Java'] | 5 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Java Solution, Beats 100.00% | java-solution-beats-10000-by-mohit-005-fu1p | Intuition\n\nThe problem requires finding critical points in a linked list and then determining the minimum and maximum distances between these critical points. | Mohit-005 | NORMAL | 2024-07-05T02:16:20.129516+00:00 | 2024-07-05T02:16:20.129544+00:00 | 2,174 | false | # Intuition\n\nThe problem requires finding critical points in a linked list and then determining the minimum and maximum distances between these critical points. A critical point in a linked list is defined as a node that is either a local maximum or a local minimum. The key challenge is to efficiently identify these ... | 39 | 1 | ['Java'] | 3 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 2058. Find the Minimum and Maximum Number of Nodes Between Critical Points | 2058-find-the-minimum-and-maximum-number-rg8c | Code\n\nclass Solution {\n public int[] nodesBetweenCriticalPoints(ListNode head) {\n int[] ans = {-1, -1};\n if (head == null || head.next == | DoaaOsamaK | NORMAL | 2024-07-05T03:12:53.973157+00:00 | 2024-07-05T03:12:53.973180+00:00 | 658 | false | # Code\n```\nclass Solution {\n public int[] nodesBetweenCriticalPoints(ListNode head) {\n int[] ans = {-1, -1};\n if (head == null || head.next == null || head.next.next == null) return ans;\n\n ListNode pre = head;\n ListNode cur = head.next;\n int prePosition = -1, curPosition =... | 36 | 0 | ['Java'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | ✅ Short & Easy | c++ | short-easy-c-by-rajat_gupta-7jor | TC : O(n)\nSC : O(n)\n\nclass Solution {\npublic:\n vector<int> nodesBetweenCriticalPoints(ListNode* head) {\n ListNode *prev=head;\n head=head | rajat_gupta_ | NORMAL | 2021-10-31T04:01:42.554940+00:00 | 2021-10-31T04:16:12.224441+00:00 | 3,782 | false | **TC : O(n)\nSC : O(n)**\n```\nclass Solution {\npublic:\n vector<int> nodesBetweenCriticalPoints(ListNode* head) {\n ListNode *prev=head;\n head=head->next;\n int i=1;\n vector<int> index;\n while(head->next){\n if((prev->val < head->val and head->val > head->next->val)... | 36 | 6 | ['C', 'C++'] | 4 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Python 3 || 11 lines, w/ explanation || T/S: 82% / 88% | python-3-11-lines-w-explanation-ts-82-88-dh7a | \nclass Solution:\n def nodesBetweenCriticalPoints(self, head: ListNode) -> List[int]:\n\n ct, critPts, prev = 0, [], head.val | Spaulding_ | NORMAL | 2022-10-18T21:56:45.564852+00:00 | 2024-07-05T03:37:15.774574+00:00 | 796 | false | ```\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: ListNode) -> List[int]:\n\n ct, critPts, prev = 0, [], head.val # keep track of node-count, critical points\n # encountered, and previous node value\n ... | 14 | 0 | ['Python', 'Python3'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 😍 BEGINNERS FRIENDLY ||✅ 💯% ON RUNTIME ||✌️ EASY || O(n) 🏃♂️ AND O(1) 🚀 | beginners-friendly-on-runtime-easy-on-an-e8vg | Intuition \uD83D\uDCA1\n Describe your first thoughts on how to solve this problem. \n\nThe problem seems to involve identifying critical points in a singly-lin | IamHazra | NORMAL | 2024-03-25T19:56:20.636556+00:00 | 2024-03-25T19:59:10.835990+00:00 | 507 | false | # Intuition \uD83D\uDCA1\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nThe problem seems to involve identifying critical points in a singly-linked list and calculating the distances between them. One potential approach could be to iterate through the list while keeping track of critical points... | 12 | 0 | ['Linked List', 'Math', 'Two Pointers', 'C++', 'Java', 'JavaScript'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | One Pass Explained | Time O(N) | Space O(1) | one-pass-explained-time-on-space-o1-by-n-r7qy | Keep Two Pointers - One for traversing "curr" in my solution and "prev" to track last node\n To make solution simple declare variables for minDistance with larg | nikhilnagrale2 | NORMAL | 2021-11-02T22:47:01.571996+00:00 | 2021-11-20T15:46:11.798041+00:00 | 1,199 | false | * Keep Two Pointers - One for traversing "curr" in my solution and "prev" to track last node\n* To make solution simple declare variables for minDistance with large value, maxDistance as smallest value, length (size), First Critical Point ( first ) and Previous Critical Point ( preCP ).\n* While traversing a linkedList... | 12 | 1 | ['Linked List', 'C'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Best solution which is no less than EDITORIAL.. beats 98.6% users.. | best-solution-which-is-no-less-than-edit-ofgu | \n\n# Code\n\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n result = [-1, -1]\n\n # Initiali | Aim_High_212 | NORMAL | 2024-07-05T01:43:17.806051+00:00 | 2024-07-05T01:43:17.806072+00:00 | 40 | false | \n\n# Code\n```\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n result = [-1, -1]\n\n # Initialize minimum distance to the maximum possible value\n min_distance = float("inf")\n\n # Pointers to track the previous node, current node, and in... | 9 | 0 | ['Linked List', 'C', 'Python', 'C++', 'Java', 'Python3'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Easy solution (imo). TC - O(n), SC - O(n) | easy-solution-imo-tc-on-sc-on-by-movsar-1e1m | python\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n # Initialize pointers for traversing the list | movsar | NORMAL | 2024-07-05T00:59:49.716404+00:00 | 2024-07-05T07:11:16.240073+00:00 | 873 | false | ```python\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n # Initialize pointers for traversing the list\n left = head\n mid = head.next\n\n # Check if the list has at least three nodes\n if not mid.next:\n return [-1, -1]... | 9 | 1 | ['Python3'] | 4 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Short and Easy c++ , Beginner Friendly. | short-and-easy-c-beginner-friendly-by-rn-n5b1 | This is a very simple approach and easy to understand for beginners \nFor sake of understanding \nlets consider a example :\n Input: head = [5,3,1,2,5,1,2]\n s | rnurchal | NORMAL | 2021-10-31T04:45:39.852350+00:00 | 2021-10-31T04:45:39.852378+00:00 | 705 | false | This is a very simple approach and easy to understand for beginners \nFor sake of understanding \nlets consider a example :\n Input: head = [5,3,1,2,5,1,2]\n so here what will be the next step;\n lets take a empty vector of int;\n i have attached a image check it out.\n 1. it will [ \n {\ | shishirRsiam | NORMAL | 2024-07-05T03:42:01.798195+00:00 | 2024-07-05T03:42:01.798227+00:00 | 1,676 | false | # if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code\n```\nclass Solution {\npublic:\n vector<int> nodesBetweenCriticalPoints(ListNode* head) \n {\n vector<int>store;\n\n int ans1 = INT_MAX, cur, next, n;\n int last = head->val, position = 2;\n\n while(head->next)\n ... | 7 | 0 | ['Linked List', 'C++'] | 3 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Python || Easy Solution | python-easy-solution-by-naveenrathore-x3se | class Solution:\n\t\n\tdef nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n \n prev = None\n temp = head\n | naveenrathore | NORMAL | 2021-11-04T09:08:46.679231+00:00 | 2021-11-04T09:08:46.679259+00:00 | 1,145 | false | class Solution:\n\t\n\tdef nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n \n prev = None\n temp = head\n \n mini, maxi = 10 ** 5, 0\n count = 1\n \n diff = 10 ** 5\n while temp.next.next != None:\n prev = temp\n ... | 7 | 2 | ['Linked List', 'Python', 'Python3'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | BEET 100% | beet-100-by-ayu7054-jdpn | 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 | Ayu7054 | NORMAL | 2023-12-20T08:48:51.895259+00:00 | 2023-12-20T08:48:51.895283+00:00 | 139 | 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)$$ --... | 6 | 0 | ['Python3'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Easy JAVA soln, beats 100%, without using array/arraylist | easy-java-soln-beats-100-without-using-a-5ua3 | Traversing the Linked-List to check for the critical points and maintaining theminimum_index , last_index and current_index\nAlso checking for the minimum dista | waynebruce1704 | NORMAL | 2021-10-31T10:06:56.611069+00:00 | 2021-10-31T10:06:56.611110+00:00 | 1,131 | false | Traversing the Linked-List to check for the critical points and maintaining the` minimum_index , last_index and current_index`\nAlso checking for the minimum distance between the critical point index at each traversal.\nThe maximum distance at end of traversal will be `current_index - minimum_index`\n\n```\nclass Solut... | 6 | 1 | ['Linked List', 'Java'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | simple and easy Python solution 😍❤️🔥 | simple-and-easy-python-solution-by-shish-skj3 | if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code\n\nclass Solution(object):\n def nodesBetweenCriticalPoints(self, head):\n store = []\n | shishirRsiam | NORMAL | 2024-07-05T03:51:32.398735+00:00 | 2024-07-05T03:51:32.398765+00:00 | 575 | false | # if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code\n```\nclass Solution(object):\n def nodesBetweenCriticalPoints(self, head):\n store = []\n ans1 = float(\'inf\')\n last, position = head.val, 2\n head = head.next\n \n while head and head.next:\n cur... | 5 | 0 | ['Linked List', 'Python', 'Python3'] | 5 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Solution for LeetCode#2058 | solution-for-leetcode2058-by-samir023041-famq | \n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nWe need to iterate through the linked list to identify the critical points. As we | samir023041 | NORMAL | 2024-07-05T02:52:04.213068+00:00 | 2024-07-05T02:52:04.213091+00:00 | 62 | false | \n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe need to iterate through the linked list to identify the critical points. As we find each critical point, we should ke... | 5 | 0 | ['Java'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | C++ Simple and Clean Solution, Detailed Explanation, O(n) TC O(1) SC | c-simple-and-clean-solution-detailed-exp-m0px | Idea:\nWe loop through the list, and check each node if it\'s critical using helper function isCritical.\nIf it\'s critical, we save in mn the minimum distance | yehudisk | NORMAL | 2021-10-31T10:37:39.488317+00:00 | 2021-10-31T10:37:39.488347+00:00 | 514 | false | **Idea:**\nWe loop through the list, and check each node if it\'s critical using helper function `isCritical`.\nIf it\'s critical, we save in `mn` the minimum distance between two close critical points.\nWe also save in `first_crit` the index of the first critical point.\nLast, we update `prev_crit` to the current `idx... | 5 | 1 | ['C'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Beats 95.89% Simple approach | beats-9589-simple-approach-by-prakhartya-0885 | \n# Approach\nThe solution iterates through the linked list to identify critical points, storing their positions. It then calculates the minimum and maximum dis | prakhartyagi | NORMAL | 2024-07-05T17:40:32.406170+00:00 | 2024-07-05T17:40:32.406189+00:00 | 5 | false | \n# Approach\nThe solution iterates through the linked list to identify critical points, storing their positions. It then calculates the minimum and maximum distances between all pairs of these critical points. If fewer than two critical points are found, it returns {-1, -1}.\n\n# Complexity\n- Time complexity:\n O(... | 4 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Solution Solved using the help of ZOO (jurel) | solution-solved-using-the-help-of-zoo-ju-jhl7 | Intuition\n Describe your first thoughts on how to solve this problem. \nCreate a vector to store positions of the critical points, and return min and maximum d | udhaykondeti004 | NORMAL | 2024-07-05T16:27:15.413928+00:00 | 2024-07-05T16:27:15.413959+00:00 | 49 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nCreate a vector to store positions of the critical points, and return min and maximum distances\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Take a pointer temp to store previous node and ptr to store current ... | 4 | 0 | ['C++'] | 5 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 2058. Find the Minimum and Maximum Number of Nodes || INTUITIVE || EASY || BEATS 90.46% | 2058-find-the-minimum-and-maximum-number-51i3 | \n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nTraverse the linked list , comparing it with previous ans next node to find criri | k-arsyn28 | NORMAL | 2024-07-05T10:04:53.862462+00:00 | 2024-07-05T10:04:53.862500+00:00 | 12 | false | \n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTraverse the linked list , comparing it with previous ans next node to find crirical point and , updating current-pointe... | 4 | 0 | ['Linked List', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Simple Java || C++ Code ☠️ | simple-java-c-code-by-abhinandannaik1717-9uem | java []\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n * int val;\n * ListNode next;\n * ListNode() {}\n * ListNode(i | abhinandannaik1717 | NORMAL | 2024-07-05T03:49:53.317275+00:00 | 2024-07-05T03:49:53.317305+00:00 | 479 | false | ```java []\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[] nod... | 4 | 0 | ['Linked List', 'C++', 'Java'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 💡 C++ | O(n) | Beats 99% | Simple Logic | With Full Explanation ✏️ | c-on-beats-99-simple-logic-with-full-exp-b4kj | \n# Approach\n1. Traverse the Linked List: Convert the linked list to a vector of values for easier access.\n2. Identify Critical Points: Traverse the vector to | Tusharr2004 | NORMAL | 2024-07-05T03:07:35.536850+00:00 | 2024-07-05T03:08:46.248099+00:00 | 13 | false | \n# Approach\n1. **Traverse the Linked List:** Convert the linked list to a vector of values for easier access.\n2. **Identify Critical Points:** Traverse the vector to find critical points, which are defined as nodes where the value is either greater than both its neighboring values or less than both its neighboring v... | 4 | 0 | ['Linked List', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | simple sol | simple-sol-by-abichal-webr | Intuition\nGo through the linked list and simply find the critical points. Compare these critical points to find the solution\n\n# Approach\nKeep a pointer for | abichal | NORMAL | 2024-07-05T00:27:49.314564+00:00 | 2024-07-05T00:27:49.314588+00:00 | 225 | false | # Intuition\nGo through the linked list and simply find the critical points. Compare these critical points to find the solution\n\n# Approach\nKeep a pointer for prev, curr and next to find the critical points. Add the position in an array and then calculate the minimum distance and the maximum distance.\n\n# Complexit... | 4 | 0 | ['Python3'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | [Python 3] 2 solutions: save all critical points, then calculate result or calculate distance on fly | python-3-2-solutions-save-all-critical-p-vhoz | python3 []\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n idx, i = [], 1\n prev, cur = head, | yourick | NORMAL | 2023-07-26T16:19:54.520162+00:00 | 2024-07-05T00:49:59.888036+00:00 | 291 | false | ```python3 []\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n idx, i = [], 1\n prev, cur = head, head.next\n while cur and cur.next:\n if prev.val < cur.val > cur.next.val or prev.val > cur.val < cur.next.val:\n idx.appe... | 4 | 0 | ['Linked List', 'Python', 'Python3'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | C++ Solution with Comments | c-solution-with-comments-by-abhi_vee-ga93 | \nclass Solution {\npublic:\n vector<int> nodesBetweenCriticalPoints(ListNode* head) \n { \n vector<int> v; // v to store critical point locatio | abhi_vee | NORMAL | 2021-10-31T04:01:25.710809+00:00 | 2021-10-31T04:03:29.486131+00:00 | 296 | false | ```\nclass Solution {\npublic:\n vector<int> nodesBetweenCriticalPoints(ListNode* head) \n { \n vector<int> v; // v to store critical point locations\n ListNode*prev = head; ListNode* curr = head->next; ListNode* ahead = head->next->next;\n int i=2;\n \n while(curr->next != N... | 4 | 0 | ['C', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 99% Running time | Easy to understand | 99-running-time-easy-to-understand-by-li-kv3k | Intuition\n Describe your first thoughts on how to solve this problem. \nCritical points in a linked list are nodes where the value is either a local maximum or | LinhNguyen310 | NORMAL | 2024-07-05T13:53:43.481109+00:00 | 2024-07-05T13:53:43.481149+00:00 | 6 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nCritical points in a linked list are nodes where the value is either a local maximum or a local minimum. A local maximum is a node whose value is greater than its neighbors, and a local minimum is a node whose value is smaller than its ne... | 3 | 0 | ['Python'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 99% Running time | Easy to understand | 99-running-time-easy-to-understand-by-li-kpjz | Intuition\n Describe your first thoughts on how to solve this problem. \nCritical points in a linked list are nodes where the value is either a local maximum or | LinhNguyen310 | NORMAL | 2024-07-05T13:53:42.593074+00:00 | 2024-07-05T13:53:42.593106+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nCritical points in a linked list are nodes where the value is either a local maximum or a local minimum. A local maximum is a node whose value is greater than its neighbors, and a local minimum is a node whose value is smaller than its ne... | 3 | 0 | ['Python'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | C# Solution for Find the Minimum and Maximum Number of Nodes Between Critical Points Problem | c-solution-for-find-the-minimum-and-maxi-owyt | Intuition\n Describe your first thoughts on how to solve this problem. \nThe task is to find the minimum and maximum distances between critical points (local ma | Aman_Raj_Sinha | NORMAL | 2024-07-05T12:02:10.373117+00:00 | 2024-07-05T12:02:10.373140+00:00 | 101 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe task is to find the minimum and maximum distances between critical points (local maxima or minima) in a linked list. The approach involves two main steps: first, identify and store the indices of all critical points, and second, compu... | 3 | 0 | ['C#'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Easy One Pass Solution Explained✅🏆 | easy-one-pass-solution-explained-by-_ris-ti6t | Nodes Between Critical Points\n\n## Problem Description\n\nGiven a singly linked list, we need to find the minimum and maximum distances between critical points | _Rishabh_96 | NORMAL | 2024-07-05T10:42:51.131086+00:00 | 2024-07-05T10:42:51.131137+00:00 | 69 | false | # Nodes Between Critical Points\n\n## Problem Description\n\nGiven a singly linked list, we need to find the minimum and maximum distances between critical points in the list. A critical point in the list is defined as a node that is either a local minimum or a local maximum. A node is a local minimum if it is smaller ... | 3 | 0 | ['Linked List', 'C++'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Single Pass Solution | Java | C++ | single-pass-solution-java-c-by-lazy_pota-uuxw | Intuition,approach, and complexity discussed in video solution in detail\nhttps://youtu.be/Yq9W_ryX9OA\n# Code\nJava\n\nclass Solution {\n public int[] nodes | Lazy_Potato_ | NORMAL | 2024-07-05T06:54:13.860874+00:00 | 2024-07-05T06:54:13.860901+00:00 | 397 | false | # Intuition,approach, and complexity discussed in video solution in detail\nhttps://youtu.be/Yq9W_ryX9OA\n# Code\nJava\n```\nclass Solution {\n public int[] nodesBetweenCriticalPoints(ListNode head) {\n int minDist = Integer.MAX_VALUE, maxDist = Integer.MIN_VALUE;\n ListNode prevNode = head;\n i... | 3 | 0 | ['Linked List', 'C++', 'Java'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | JavaScript Simple Solution, Beats 98% time complexity and 92% space complexity | javascript-simple-solution-beats-98-time-kjz3 | Intuition\nThe code aims to find the minimum and maximum distances between critical points in a linked list. A critical point is defined as a node where the val | briancode99 | NORMAL | 2024-07-05T06:22:34.443002+00:00 | 2024-07-05T06:22:34.443037+00:00 | 33 | false | # Intuition\nThe code aims to find the minimum and maximum distances between critical points in a linked list. A critical point is defined as a node where the value is strictly greater or strictly lesser than its immediate neighbors. My initial thought is that we need to traverse the linked list, identify these critica... | 3 | 0 | ['JavaScript'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Traverse through the list and capture the indices, Easy to understand solution. | traverse-through-the-list-and-capture-th-que8 | Intuition\nWe simply just need to find the indices of the local maxima and local minimas. Since the indexing here is starting from 1, We will keep that in mind | sxnchayyyy | NORMAL | 2024-07-05T06:10:35.744247+00:00 | 2024-07-05T06:10:35.744282+00:00 | 244 | false | # Intuition\nWe simply just need to find the indices of the local maxima and local minimas. Since the indexing here is starting from 1, We will keep that in mind and traverse through the array looking for asked maxima and minimas and we will store their indices as we move forward.\n\n# Approach\nTraverse through the li... | 3 | 0 | ['C++'] | 6 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Beginner-Friendly C++ Solution || Easy to Understand || T.C. O(n) || One Stop Solution. | beginner-friendly-c-solution-easy-to-und-l4qq | Intuition\nCritical points in a linked list are nodes where the value is either a local minimum or maximum. To find the minimum and maximum distances between cr | omkarsalunkhe3597 | NORMAL | 2024-07-05T04:48:49.764594+00:00 | 2024-07-05T04:48:49.764638+00:00 | 150 | false | # Intuition\nCritical points in a linked list are nodes where the value is either a local minimum or maximum. To find the minimum and maximum distances between critical points, we need to identify and record their positions, then compute the required distances.\n\n# Approach\n1. Traverse the list with three pointers: `... | 3 | 0 | ['Linked List', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | {C++} O(1) Space, Single Pass, Beats 100%, Detailed Explanation. | c-o1-space-single-pass-beats-100-detaile-v6c9 | What is the question asking for\u2753\n Describe your approach to solving the problem. \nWe need to find critical points in the linked list where the value of a | Ashmit_Mehta | NORMAL | 2024-07-05T03:38:03.522233+00:00 | 2024-07-12T03:17:42.969628+00:00 | 72 | false | ## *What is the question asking for\u2753*\n<!-- Describe your approach to solving the problem. -->\nWe need to find **critical** points in the linked list where the value of a node is either:\n\n- **Greater** than its **previous** and **next** nodes (forming a peak).\n\n- **Less** than its **previous** and **next** no... | 3 | 0 | ['Linked List', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Java Simple Clean solution | with Detail Explanatin | java-simple-clean-solution-with-detail-e-xsnm | Approach\n Describe your approach to solving the problem. \nTo make it simple, we track:\n\n- first and last indexes of local min/max.\n- the value of the previ | Shree_Govind_Jee | NORMAL | 2024-07-05T03:31:32.439784+00:00 | 2024-07-05T03:31:32.439813+00:00 | 239 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nTo make it simple, we track:\n\n- first and last indexes of local **`min/max`**.\n- the value of the previous node **`prev`**.\n- smallest difference between two adjacent indices **`(current i - idx)`** as **`min_d`**.\n- The result is `new int[] {min... | 3 | 0 | ['Linked List', 'Math', 'Two Pointers', 'Doubly-Linked List', 'Java'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Easy C++ Solution with video Explanation | easy-c-solution-with-video-explanation-b-nesz | Video Explanation\nhttps://youtu.be/s_4qH7ldP7A\n# Intuition\n Describe your first thoughts on how to solve this problem. \nThe task is to find critical points | prajaktakap00r | NORMAL | 2024-07-05T00:48:01.524357+00:00 | 2024-07-05T00:48:01.524403+00:00 | 573 | false | # Video Explanation\nhttps://youtu.be/s_4qH7ldP7A\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe task is to find critical points in a linked list and calculate the minimum and maximum distances between these points. Critical points are nodes that are either local maxima or local ... | 3 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 90% TC and 87% SC easy python solution | 90-tc-and-87-sc-easy-python-solution-by-x9tcc | \ndef nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n\tans = [float(\'inf\'), -float(\'inf\')]\n\tcurr = head.next\n\tprev = head\n\t | nitanshritulon | NORMAL | 2022-09-03T07:51:53.195089+00:00 | 2022-09-03T07:51:53.195121+00:00 | 493 | false | ```\ndef nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n\tans = [float(\'inf\'), -float(\'inf\')]\n\tcurr = head.next\n\tprev = head\n\ti = 1\n\tpos = []\n\twhile(curr.next):\n\t\tif(prev.val < curr.val > curr.next.val):\n\t\t\tpos.append(i)\n\t\telif(prev.val > curr.val < curr.next.val):\n\t... | 3 | 0 | ['Linked List', 'Python', 'Python3'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Java || Easy Beginner Solution | java-easy-beginner-solution-by-devansh28-1o0i | \nclass Solution {\n public int[] nodesBetweenCriticalPoints(ListNode head) {\n List<Integer> list = new ArrayList<>();\n while(head != null) { | devansh2805 | NORMAL | 2022-04-07T14:41:54.603992+00:00 | 2022-04-07T14:41:54.604044+00:00 | 157 | false | ```\nclass Solution {\n public int[] nodesBetweenCriticalPoints(ListNode head) {\n List<Integer> list = new ArrayList<>();\n while(head != null) {\n list.add(head.val);\n head = head.next;\n }\n if(list.size() <= 2) {\n return new int[]{-1, -1};\n }... | 3 | 0 | ['Java'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Solution in Java | solution-in-java-by-farizma-mzwh | class Solution {\n \n public int[] nodesBetweenCriticalPoints(ListNode head) {\n \n //int[] res = {-1, -1};\n int min = Integer.MAX_V | farizma | NORMAL | 2021-11-02T02:01:07.819234+00:00 | 2021-11-02T02:01:07.819289+00:00 | 67 | false | class Solution {\n \n public int[] nodesBetweenCriticalPoints(ListNode head) {\n \n //int[] res = {-1, -1};\n int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;\n int FirstCP_index = -1, LastCP_index = -1;\n \n int prev = head.val;\n head = head.next;\n i... | 3 | 0 | [] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Python Easy Solution | python-easy-solution-by-rnyati2000-0ofh | \n\n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\n | rnyati2000 | NORMAL | 2021-10-31T05:41:32.297346+00:00 | 2021-10-31T05:41:32.297378+00:00 | 248 | false | ```\n\n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n l = []\n while head:\n x = head.... | 3 | 2 | ['Python'] | 3 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Easy || One pass || Fast || Java Solution | easy-one-pass-fast-java-solution-by-iamc-cszx | \nclass Solution {\n\n\n\n public int[] nodesBetweenCriticalPoints(ListNode head)\n {\n ListNode temp=head.next;\n int min1=-1;\n Lis | IAmCoderrr | NORMAL | 2021-10-31T05:31:54.134365+00:00 | 2021-10-31T05:31:54.134401+00:00 | 263 | false | `\nclass Solution {\n\n\n\n public int[] nodesBetweenCriticalPoints(ListNode head)\n {\n ListNode temp=head.next;\n int min1=-1;\n ListNode prev=head;\n int min=Integer.MAX_VALUE;\n int pre=-1;\n int i=1;\n while(temp.next!=null){\n if((prev.val>temp.val... | 3 | 1 | ['Java'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Very Easy Solution java with detailed explanation!! | very-easy-solution-java-with-detailed-ex-i1kl | Approach\n\n1. Initialization:\n\n- Track Critical Points:\n - Initialize variables firstindex and lastindex to track the indices of the first and last critica | Digvijay_Tadage | NORMAL | 2024-09-02T17:25:13.464276+00:00 | 2024-09-02T17:25:13.464301+00:00 | 7 | false | ### Approach\n\n**1. Initialization:**\n\n- **Track Critical Points:**\n - Initialize variables `firstindex` and `lastindex` to track the indices of the first and last critical points found in the linked list.\n - Use `prevIdx` to store the index of the previous critical point encountered.\n\n- **Smallest Distance:**... | 2 | 0 | ['Java'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | C++ || Easy to understand approach for beginner | c-easy-to-understand-approach-for-beginn-6ejm | 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 | that_1guy__ | NORMAL | 2024-07-09T14:11:13.720670+00:00 | 2024-07-09T14:11:29.618645+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 2 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Simple C++ solution | Constant space | No extra memory needed for critical points | simple-c-solution-constant-space-no-extr-x71g | Intuition\nThe minimum difference between two critical points is difference between the last and second last point and the maximum difference is difference betw | saurabhdamle11 | NORMAL | 2024-07-05T21:16:24.842726+00:00 | 2024-07-05T21:16:24.842743+00:00 | 18 | false | # Intuition\nThe minimum difference between two critical points is difference between the last and second last point and the maximum difference is difference between the first and the last critical point.\n\n# Approach\n1. Initialize three pointers: prev, current and forward.\n2. Store the index of first critical point... | 2 | 0 | ['Linked List', 'C++'] | 2 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Beats ✅✅✅ 100% ✅✅✅ JAVA. | beats-100-java-by-saiswaroop1234-hy4m | Intuition\nBeats 100%. No need to store previous node value.\n\n# Approach\nTraverse through the loop only once if one critical point is found then search for a | SaiSwaroop1234 | NORMAL | 2024-07-05T17:34:55.155006+00:00 | 2024-07-05T17:34:55.155044+00:00 | 6 | false | # Intuition\nBeats 100%. No need to store previous node value.\n\n# Approach\nTraverse through the loop only once if one critical point is found then search for another other wise return [-1,-1] and repeat it once again.\n\nNow if we have more than two critical points we need to store the first critical node position a... | 2 | 0 | ['Java'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | SC: O(1), TC: O(n) | One pass | Simple approach | sc-o1-tc-on-one-pass-simple-approach-by-fzeyp | Intuition\n Describe your first thoughts on how to solve this problem. \nThere is no requirement to store every critical point!\n\n# Approach\n Describe your ap | AnishDhomase | NORMAL | 2024-07-05T17:13:10.897744+00:00 | 2024-07-05T17:16:54.319791+00:00 | 21 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThere is no requirement to store every critical point!\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. `isCriticalPoint` function checks critical point.\n\n2. Now, we go through the linked list once, from start ... | 2 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | C++ Code for Beginners | c-code-for-beginners-by-manral_0203-4qc4 | Intuition\n Describe your first thoughts on how to solve this problem. \nThe given code aims to find the minimum and maximum distances between critical points i | Manral_0203 | NORMAL | 2024-07-05T15:04:43.241043+00:00 | 2024-07-05T15:04:43.241077+00:00 | 94 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe given code aims to find the minimum and maximum distances between critical points in a singly-linked list. A critical point is defined as a node in the linked list where the node is either a local maximum or a local minimum. Here\'s a... | 2 | 0 | ['Linked List', 'C++'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Extremely Intuitive 🔥 Intuitive C++ Approach 🔥🔥 | extremely-intuitive-intuitive-c-approach-tntm | Intuition\nWe need to find elements n which satisfy either of the conditions:\n\ni. current node has value greater than both, previous and next node\nii. curren | peakfor | NORMAL | 2024-07-05T11:08:29.870792+00:00 | 2024-07-05T11:08:29.870834+00:00 | 0 | false | # Intuition\nWe need to find elements n which satisfy either of the conditions:\n\ni. current node has value greater than both, previous and next node\nii. current node has value lesser than both, previous and next node\n\n# Approach\n1) use \'size\' variable to keep track of size of the linked list\n2) \'maxidx\' to s... | 2 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Python | Single Pass Traversal | python-single-pass-traversal-by-khosiyat-uacs | see the Successfully Accepted Submission\n\n# Code\n\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n | Khosiyat | NORMAL | 2024-07-05T08:59:25.862941+00:00 | 2024-07-05T08:59:25.862965+00:00 | 218 | false | [see the Successfully Accepted Submission](https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/submissions/1310271690/?envType=daily-question&envId=2024-07-05)\n\n# Code\n```\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:... | 2 | 0 | ['Python3'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | ✅💯🔥Explanations No One Will Give You🎓🧠Detailed Approach🎯🔥Extremely Simple And Effective🔥 | explanations-no-one-will-give-youdetaile-w94u | Intuition\nWe just want to get all the critical point\'s index of linked list.\nAs we got their index , we will find out the minimum difference and maximum diff | madhurpratap7355 | NORMAL | 2024-07-05T08:38:45.074319+00:00 | 2024-07-05T08:47:23.528449+00:00 | 23 | false | # Intuition\nWe just want to get all the critical point\'s index of linked list.\nAs we got their index , we will find out the minimum difference and maximum difference between them .\n\n# Approach\n**Case 1:** if nodes count <=2 return {-1,-1}\n\n---\n**Case 2:** we will use three pointer which will point to first sec... | 2 | 0 | ['Linked List', 'Two Pointers', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | ✅ Easy C++ Solution | easy-c-solution-by-moheat-b1cz | Code\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\ | moheat | NORMAL | 2024-07-05T08:36:02.883850+00:00 | 2024-07-05T08:36:02.883880+00:00 | 101 | false | # Code\n```\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\n bool ... | 2 | 0 | ['C++'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | EASY || BEGINNER || SIMULATE AS IT IS. | easy-beginner-simulate-as-it-is-by-abhis-7sjr | Hey fellas,This code defines a function nodesBetweenCriticalPoints(ListNode head) that takes the head of a linked list and returns an array containing two integ | Abhishekkant135 | NORMAL | 2024-07-05T08:08:31.416752+00:00 | 2024-07-05T08:08:31.416776+00:00 | 76 | false | Hey fellas,This code defines a function `nodesBetweenCriticalPoints(ListNode head)` that takes the head of a linked list and returns an array containing two integers:\n\n- Minimum distance between any two critical points (local maxima or minima) in the linked list.\n- Maximum distance between any two critical points.\n... | 2 | 0 | ['Linked List', 'Java'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | O(1) Space, Straightforward | o1-space-straightforward-by-suthiwat-osqu | Approach\nTraverse through linked list while keeping track of prev, prev_i, first_i where\n- prev is a value of previous list node\n- prev_i is an index of prev | suthiwat | NORMAL | 2024-07-05T07:44:06.911357+00:00 | 2024-07-05T07:44:06.911380+00:00 | 24 | false | # Approach\nTraverse through linked list while keeping track of `prev`, `prev_i`, `first_i` where\n- `prev` is a value of previous list node\n- `prev_i` is an index of previous critical node\n- `first_i` is an index of first critical node\n\n`prev` will be use to determine if the current node is a critical or not. When... | 2 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Easy C++ Solution || Efficient 2 Pointers Approach || Beats 98% | easy-c-solution-efficient-2-pointers-app-wtw7 | \n\n\n# Approach\n Describe your approach to solving the problem. \nUsing Two pointer to update the max and min distance.\n\n# Complexity\n- Time complexity: O( | DecafCoder0312 | NORMAL | 2024-07-05T07:40:14.894058+00:00 | 2024-07-05T07:40:14.894083+00:00 | 59 | false | \n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUsing Two pointer to update the max and min distance.\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, ... | 2 | 0 | ['Linked List', 'Two Pointers', 'C++'] | 2 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 🚀🚀Single Iteration & O(1) Space Code C++🔥🔥💯 | single-iteration-o1-space-code-c-by-syed-9h3z | Code\n\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\ | Syed_Affan | NORMAL | 2024-07-05T07:06:36.197707+00:00 | 2024-07-05T07:06:36.197743+00:00 | 54 | false | # Code\n```\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n */\nclass Solution {\npublic:\n... | 2 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | [C | C++] -> Solution | c-c-solution-by-zhanghx04-jjgj | 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 | zhanghx04 | NORMAL | 2024-07-05T06:41:31.609381+00:00 | 2024-07-05T06:43:49.499527+00:00 | 8 | 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```C []\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * struct ListNode *next;\n ... | 2 | 0 | ['Linked List', 'C', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Efficiently Find Distances Between Critical Points in a Linked List ✅🧑💻 | efficiently-find-distances-between-criti-pgnd | 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 | muhammadsahad | NORMAL | 2024-07-05T06:15:12.449053+00:00 | 2024-07-05T06:15:12.449082+00:00 | 37 | 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 c**Bold**omplexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O ( n )\n<!-- Add your space complexit... | 2 | 0 | ['JavaScript'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 🚀 Find Nodes Between Critical Points in Linked List! 🔗 Beats 57% ✨Memory Efficiency 82% | find-nodes-between-critical-points-in-li-xqul | \n\n# Intuition\nTo determine the distances between critical points in a linked list, we need to identify nodes that represent local maxima or minima. By traver | UDAY-SANKAR-MUKHERJEE | NORMAL | 2024-07-05T05:46:04.987857+00:00 | 2024-07-05T05:46:04.987887+00:00 | 42 | false | \n\n# Intuition\nTo determine the distances between critical points in a linked list, we need to identify nodes that represent local maxima or minima. By traversing the list and tracking these critical poin... | 2 | 0 | ['Python3'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Simple Solution | simple-solution-by-csivaprakash-qxjk | Approch\n\nWe define previous node for compare the current node value to its previous node value and take the current node from next node to the head. \n\nThen | csivaprakash | NORMAL | 2024-07-05T04:55:39.723617+00:00 | 2024-07-06T16:44:16.016640+00:00 | 65 | false | # Approch\n\nWe define previous node for compare the current node value to its previous node value and take the current node from next node to the head. \n\nThen define startingPosition and previousPosition with value -1 and position (current position of the current node) with value 1.\n\nThen define int array of resul... | 2 | 0 | ['Linked List', 'C#'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 🚀Fast and ✔️Easiest Solution in C++[129 ms Beats 97.43%] | fast-and-easiest-solution-in-c129-ms-bea-srsl | 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 | zishan_0point1 | NORMAL | 2024-07-05T04:23:58.346612+00:00 | 2024-07-05T04:23:58.346651+00:00 | 94 | 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 | ['Linked List', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Best Approach💯 | best-approach-by-adwxith-qax6 | Please let me know if this solution works for you. If you find it helpful, an upvote would be greatly appreciated!\uD83E\uDEE1\n\n# Complexity\n- Time complexit | adwxith | NORMAL | 2024-07-05T04:12:17.952638+00:00 | 2024-07-05T04:12:17.952666+00:00 | 126 | false | # Please let me know if this solution works for you. If you find it helpful, an upvote would be greatly appreciated!\uD83E\uDEE1\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\n/**\n * Definition for singly-linked list.\n * function ListNode(val, next) {\n * this.val = (val===... | 2 | 0 | ['JavaScript'] | 2 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | || Easy simple clean code ||C++ 98.75 % || | easy-simple-clean-code-c-9875-by-srimukh-wfe0 | Intuition\n Describe your first thoughts on how to solve this problem. \nFind all the positions of Critical points and the 2 values required are minimum distanc | srimukheshsuru | NORMAL | 2024-07-05T04:11:55.513278+00:00 | 2024-07-05T04:11:55.513309+00:00 | 9 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFind all the positions of Critical points and the 2 values required are minimum distance between any 2 critical points , you can find this by traversing over the positions array once. the second value is directly ```v[v.size()-1] - v[0]`... | 2 | 0 | ['Linked List', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Python3 Solution | python3-solution-by-motaharozzaman1996-ppzl | \n\n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\n | Motaharozzaman1996 | NORMAL | 2024-07-05T02:53:04.261741+00:00 | 2024-07-05T02:53:04.261766+00:00 | 146 | false | \n```\n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n left=head\n mid=head.next\n right=mi... | 2 | 0 | ['Python', 'Python3'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | One Pass no extra space Easy Understanding ✅ | one-pass-no-extra-space-easy-understandi-cwc3 | Intuition\n\nKeep track of previous critical point and update minimum. \nfor maximum = last critical point - first critical point\n\n# Approach\n1. Identify Cri | yashwanthreddi | NORMAL | 2024-07-05T01:07:05.633776+00:00 | 2024-07-14T05:46:01.592623+00:00 | 48 | false | # Intuition\n\nKeep track of previous critical point and update minimum. \nfor maximum = last critical point - first critical point\n\n# Approach\n1. Identify Critical Points:\n\n- Traverse the linked list starting from the second node.\n- Check if a node is a local minimum or maximum by comparing its value with the pr... | 2 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Easy C++ Solution || Using vectors | easy-c-solution-using-vectors-by-orewa_a-xhh4 | Please upvote if you find this approach a little bit usefull.\n\n# Intuition\nThe question stated that we have to return the distance between the indices.\n\n# | Orewa_Abhi | NORMAL | 2024-02-27T06:45:07.405456+00:00 | 2024-02-27T06:45:07.405491+00:00 | 256 | false | # Please upvote if you find this approach a little bit usefull.\n\n# Intuition\nThe question stated that we have to return the distance between the **indices**.\n\n# Approach\n- Take a vector to store the indices of local minimas or maximas.\n- Declare an ind as 0 to count the indices of nodes.\n- Now use three pointer... | 2 | 0 | ['C++'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 100% Efficient Solution in C++ with Linear Time Complexity O(n)... | 100-efficient-solution-in-c-with-linear-2oeop | Intuition\n Describe your first thoughts on how to solve this problem. \nCheck Solution Comments written in Solution...\nDoes,...\n1). Atfirst, Read entire prob | ganpatinath07 | NORMAL | 2024-01-19T10:21:41.194385+00:00 | 2024-01-19T10:21:41.194420+00:00 | 87 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nCheck Solution Comments written in Solution...\nDoes,...\n1). Atfirst, Read entire problem...\n2). Dry run atleast 3 testcases...\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUsing Basic concepts of Linked List.... | 2 | 0 | ['Linked List', 'C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Easy Java Solution || T.C = O(n) | easy-java-solution-tc-on-by-ravikumar50-8kt0 | 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 | ravikumar50 | NORMAL | 2023-09-17T08:30:45.422010+00:00 | 2023-09-17T08:30:45.422038+00:00 | 332 | 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'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | easy c++ solution using vector || easy and optimal approach | easy-c-solution-using-vector-easy-and-op-vscn | 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 | Rhythm_1383 | NORMAL | 2023-08-20T14:32:12.703074+00:00 | 2023-08-20T14:32:12.703095+00:00 | 128 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 2 | 0 | ['C++'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Golang Time O(n), Space O(1). Runtime Beats 100% & Memory Beats 100% | golang-time-on-space-o1-runtime-beats-10-41ey | Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co | tenseiganrinnesharingan | NORMAL | 2023-03-31T19:14:53.721821+00:00 | 2023-04-01T07:40:18.724458+00:00 | 77 | false | # Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for singly-linked list.\n * type ListNode struct {\n * Val int\n * Next *ListNode\n * }\n */... | 2 | 0 | ['Go'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | c++ easy samaj me aaega bro | c-easy-samaj-me-aaega-bro-by-underdogsou-l1tw | 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 | underdogsourav | NORMAL | 2023-03-26T15:46:04.984064+00:00 | 2023-03-26T15:46:04.984101+00:00 | 391 | 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-the-minimum-and-maximum-number-of-nodes-between-critical-points | c++ || easy to understand | c-easy-to-understand-by-pawanchaudhary02-y59h | \'\'\' \nvector nodesBetweenCriticalPoints(ListNode head) {\n\n int mini=INT_MAX;\n ListNode cur=head->next,*pre=head;\n if(head==NULL | | pawanchaudhary026 | NORMAL | 2022-06-30T19:30:47.581520+00:00 | 2022-06-30T19:30:47.581566+00:00 | 196 | false | \'\'\' \nvector<int> nodesBetweenCriticalPoints(ListNode* head) {\n\n int mini=INT_MAX;\n ListNode *cur=head->next,*pre=head;\n if(head==NULL || cur->next==NULL)\n return {-1,-1};\n int ind=1;\n int ind1=0,ind2=0;\n // count is using for maxDistance by adding the di... | 2 | 0 | [] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Easy To Understand Python Solution | easy-to-understand-python-solution-by-da-1h7n | Hope this helps!\n\n~First of all, we first create two pointer, curr and prev to track previous and current node. We can keep track the node after curr using cu | danielkua | NORMAL | 2022-03-14T00:30:55.500451+00:00 | 2022-03-14T00:36:22.624364+00:00 | 82 | false | Hope this helps!\n\n~First of all, we first create two pointer, `curr` and `prev` to track previous and current node. We can keep track the node after curr using `curr.next`. So we only require 2 pointer here.\n\n~Then, we keep track the index of the curr node using `count` at the beginning and set it at 0. Whenever `... | 2 | 0 | ['Python', 'Python3'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | C++ simple and clean solution, Time O(N). | c-simple-and-clean-solution-time-on-by-p-t5kr | // By using extra space ie. a vector \n// Time O(N) Space O(N)\n\nclass Solution {\npublic:\n vector nodesBetweenCriticalPoints(ListNode head) {\n Lis | Puneet_Singh07 | NORMAL | 2022-02-07T09:31:31.688947+00:00 | 2022-02-07T09:33:54.183377+00:00 | 134 | false | // By using extra space ie. a vector \n// Time O(N) Space O(N)\n\nclass Solution {\npublic:\n vector<int> nodesBetweenCriticalPoints(ListNode* head) {\n ListNode* prev= head;\n ListNode* curr=head->next;\n ListNode* after=curr->next;\n if(prev==NULL || curr==NULL || after==NULL)\n... | 2 | 0 | ['Linked List', 'C'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | c++ easy soln | c-easy-soln-by-sahildalal23-6n7v | hint-store the indicies of critical points in array\n```\nclass Solution {\npublic:\n vector nodesBetweenCriticalPoints(ListNode head) {\n ListNode te | sahildalal23 | NORMAL | 2021-12-02T15:04:33.936995+00:00 | 2021-12-02T15:04:33.937025+00:00 | 128 | false | hint-store the indicies of critical points in array\n```\nclass Solution {\npublic:\n vector<int> nodesBetweenCriticalPoints(ListNode* head) {\n ListNode* temp=head;\n ListNode* temp2=head->next;\n vector<int> v;\n int i=1;\n while(temp2->next!=NULL)\n {\n if(temp... | 2 | 0 | [] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | (C++) 2058. Find the Minimum and Maximum Number of Nodes Between Critical Points | c-2058-find-the-minimum-and-maximum-numb-jgwh | \n\nclass Solution {\npublic:\n vector<int> nodesBetweenCriticalPoints(ListNode* head) {\n int dmin = INT_MAX, last = 0, first = 0, prev = head->val, | qeetcode | NORMAL | 2021-11-01T21:20:03.630786+00:00 | 2021-11-01T21:20:03.630817+00:00 | 146 | false | \n```\nclass Solution {\npublic:\n vector<int> nodesBetweenCriticalPoints(ListNode* head) {\n int dmin = INT_MAX, last = 0, first = 0, prev = head->val, i = 1; \n for (ListNode* node = head->next; node && node->next; prev = node->val, node = node->next, ++i) \n if ((prev < node->val && node-... | 2 | 0 | ['C'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Python3 - O(n) Time | O(1) Space | Faster than 100% | python3-on-time-o1-space-faster-than-100-b402 | \n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\ncl | yukkk | NORMAL | 2021-10-31T19:13:56.840236+00:00 | 2021-10-31T19:22:15.939935+00:00 | 209 | false | ```\n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n prev = head.val\n head = head.next\n i... | 2 | 0 | [] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Bruh this is the easiest solution you can find | bruh-this-is-the-easiest-solution-you-ca-7sd1 | maximum distance - first and last critical points\nminimum distance - between the 2 neighboring critical points\n\n/**\n * Definition for singly-linked list.\n | aparna_g | NORMAL | 2021-10-31T17:21:12.052666+00:00 | 2021-10-31T17:21:12.052708+00:00 | 136 | false | **maximum distance - first and last critical points\nminimum distance - between the 2 neighboring critical points**\n```\n/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr... | 2 | 1 | ['C', 'C++'] | 1 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Python Easy Solution : Weekly Contest 265 : Que 2058 | python-easy-solution-weekly-contest-265-le6pk | \n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\ncl | deleted_user | NORMAL | 2021-10-31T04:33:11.682041+00:00 | 2021-10-31T04:33:11.682076+00:00 | 85 | false | ```\n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\nclass Solution:\n def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]:\n s1 = []\n s2 = []\n curr = head.next\n... | 2 | 1 | ['Python3'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | ✅Beats 100% Easy O(N) C++ solution 🔥 | beats-100-easy-on-c-solution-by-bytemaes-dfsd | Complexity
Time complexity:
O(N)
Code | ByteMaestro56 | NORMAL | 2025-04-04T18:31:26.113141+00:00 | 2025-04-04T18:31:26.113141+00:00 | 9 | false |
# Complexity
- Time complexity:
O(N)
# Code
```cpp []
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* }... | 1 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | Find Critical Points, the Jedi Way | find-critical-points-the-jedi-way-by-x7f-2yq0 | IntuitionHmm... Identify peaks and valleys in the linked list we must. Like sensing the highs and lows of the Force, critical points we shall find. Between them | x7Fg9_K2pLm4nQwR8sT3vYz5bDcE6h | NORMAL | 2025-03-27T16:49:54.994352+00:00 | 2025-03-27T16:49:54.994352+00:00 | 10 | false | # Intuition
Hmm... Identify peaks and valleys in the linked list we must. Like sensing the highs and lows of the Force, critical points we shall find. Between them, the minimum and maximum distances calculate we will.
# Approach
1. Traverse the list: Examine each node with its neighbors
2. Identify critical points: Ma... | 1 | 0 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | 100% beats|| easy and simple approach|| | 100-beats-easy-and-simple-approach-by-ro-4qzo | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Rohan07_6473 | NORMAL | 2025-03-14T12:02:10.283701+00:00 | 2025-03-14T12:02:10.283701+00:00 | 15 | 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 | ['C++'] | 0 |
find-the-minimum-and-maximum-number-of-nodes-between-critical-points | C# | c-by-adchoudhary-vqex | Code | adchoudhary | NORMAL | 2025-03-05T03:51:21.415805+00:00 | 2025-03-05T03:51:21.415805+00:00 | 6 | false | # Code
```csharp []
/**
* Definition for singly-linked list.
* public class ListNode {
* public int val;
* public ListNode next;
* public ListNode(int val=0, ListNode next=null) {
* this.val = val;
* this.next = next;
* }
* }
*/
public class Solution {
public int[] NodesBet... | 1 | 0 | ['C#'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.