Тёмный

2058. Find the Minimum and Maximum Number of Nodes Between Critical Points | DSA | Hindi 

shashCode
Подписаться 16 тыс.
Просмотров 1,4 тыс.
50% 1

Problem:
2058. Find the Minimum and Maximum Number of Nodes Between Critical Points
Problem Statement:
A critical point in a linked list is defined as either a local maxima or a local minima.
A node is a local maxima if the current node has a value strictly greater than the previous node and the next node.
A node is a local minima if the current node has a value strictly smaller than the previous node and the next node.
Note that a node can only be a local maxima/minima if there exists both a previous node and a next node.
Given a linked list head, return an array of length 2 containing [minDistance, maxDistance] where minDistance is the minimum distance between any two distinct critical points and maxDistance is the maximum distance between any two distinct critical points. If there are fewer than two critical points, return [-1, -1].
Problem Link:
leetcode.com/problems/find-th...
Graph Playlist:
• Graph Data Structure S...
Java Plus DSA Placement Course Playlist:
• Java and DSA Course Pl...
Java Plus DSA Sheet:
docs.google.com/spreadsheets/...
Notes:
github.com/Tiwarishashwat/Jav...
Telegram Link:
shashwattiwari.page.link/tele...
Ultimate Recursion Series Playlist:
• Recursion and Backtrac...
Instagram Handle: (@shashwat_tiwari_st)
shashwattiwari.page.link/shas...
Samsung Interview Experience:
• I cracked Samsung | SR...
Company Tags:
Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung
Timestamp:
0:00 - Introduction
#ShashwatTiwari #coding​​ #problemsolving​

Опубликовано:

 

3 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 16   
@shashwat_tiwari_st
@shashwat_tiwari_st 26 дней назад
like target for this video is 80. Please do like if you understood the solution😄
@PiyushSharma-we8yd
@PiyushSharma-we8yd 26 дней назад
op bhaiya, aaj ka khud krliya tha, almost same approach bs aapka code kafi neat hai mere se😅😅
@RohitKumar-dz8dh
@RohitKumar-dz8dh 26 дней назад
Thanks 😊 , today I approached the problem same you did.
@kunalsarpal7564
@kunalsarpal7564 25 дней назад
thankyou so much sir ❤❤❤❤❤❤❤❤
@varadpanchal1231
@varadpanchal1231 25 дней назад
One of best explanation
@ankitagrawal4477
@ankitagrawal4477 25 дней назад
Thank you ! Today i solved these on my own😊
@GirjeshSharma-zv3xo
@GirjeshSharma-zv3xo 25 дней назад
Love from usa❤
@motivationalquotes6581
@motivationalquotes6581 24 дня назад
slow aur acha padhate ho jisse dsa ke question easy lagne laga
@deluluvish
@deluluvish 26 дней назад
thank you so much for making this video
@sankalpbarriar1029
@sankalpbarriar1029 26 дней назад
great work can you also make development related videos
@user-oi5ls4rs5g
@user-oi5ls4rs5g 26 дней назад
great
@aggarwalsachin4854
@aggarwalsachin4854 25 дней назад
hi sir, I am from upes!!
@shashwat_tiwari_st
@shashwat_tiwari_st 25 дней назад
Hello there!
@ashwinmali4338
@ashwinmali4338 25 дней назад
I had solved but the!!!!....🥲🥲 the time complexity of the solution is O(N + K log K) import java.util.ArrayList; import java.util.Collections; class ListNode { int val; ListNode next; ListNode(int x) { val = x; } } class Solution { public int[] nodesBetweenCriticalPoints(ListNode head) { // Step 1: Convert linked list to array and determine size ListNode current = head; int size = 0; ArrayList values = new ArrayList(); while (current != null) { values.add(current.val); current = current.next; size++; } // Step 2: Handle edge case for size values.get(j) && values.get(j) < values.get(j + 1)) { mini.add(j); } } ArrayList result = new ArrayList(); result.addAll(maxi); result.addAll(mini); Collections.sort(result); int[] arr = new int[result.size()]; for (int i = 0; i < result.size(); i++) { arr[i] = result.get(i); } if (arr.length >= 2) { int minDiff = Integer.MAX_VALUE; // Find the minimum difference for (int i = 1; i < arr.length; i++) { int diff = arr[i] - arr[i - 1]; if (diff < minDiff) { minDiff = diff; } } // Find the maximum difference int maxDiff = arr[arr.length - 1] - arr[0]; return new int[] {minDiff, maxDiff}; } else { return new int[] {-1, -1}; } } }
@GirjeshSharma-zv3xo
@GirjeshSharma-zv3xo 25 дней назад
Please explain this question again unable to understand 🙏🏻
@shashwat_tiwari_st
@shashwat_tiwari_st 25 дней назад
you have seen linked list playlist ? If no, please watch that first, because you should know, linked list traversal well and then only solve problems.
Далее
How I would learn Leetcode if I could start over
18:03
Просмотров 382 тыс.
NOOOOO 😂😂😂
00:15
Просмотров 6 млн
8 patterns to solve 80% Leetcode problems
7:30
Просмотров 276 тыс.
Final Verdict on MNCs Vs Startups!
11:35
Просмотров 64 тыс.
The moment we stopped understanding AI [AlexNet]
17:38
Просмотров 808 тыс.
COMPUTER SCIENCE explained in 17 Minutes
16:49
Просмотров 745 тыс.