Striver..... PLEASE CONTINUE A TO Z DSA Course....From Step 5(strings) , it is incomplete(no videos for the questions)... Your videos are very useful in intuition building and finding approach... PLEASE DONT LEAVE US IN THE MIDDLE😢😢😢...I hope you respond to the requests for the guys like me..
@bhubeshsr6281 Жыл бұрын
solve by yourself - thats his intuition
@sachinchoudhary4142 Жыл бұрын
Yes please🙏🙏
@Dipanshutripathi2407 Жыл бұрын
Yes Please
@krishnayadav5601 Жыл бұрын
yes please sir
@sachitkumbhat2004 Жыл бұрын
We love you Striverr!!!
@kathakalisaha97359 ай бұрын
Those who watches your videos completely will never say you use cpp , they are the ones who dont watch the intuition part, directly jump into the code
@saibingi6980 Жыл бұрын
I request you to please make videos in Bit Manipulation, Heaps, Strings, and Disjoint-set in the upcoming sessions.
@godson200 Жыл бұрын
He already has about 10 videos on disjoint set in the graph series. Maybe that can help.
@rekhabisht6709 Жыл бұрын
Phle itna khatm krle
@dumpster-jackson4 ай бұрын
@@rekhabisht6709 Ab??
@LemesaElias2 ай бұрын
Even if you didn't provide the pseudo code and just went to implement the C++ code, I don't think it matters because it's actually your explanation of the solutions that actually helps anyone that considers him/herself a problem solver or anyone that's learning DSA. And as someone who uses/used multiple languages, I think given the explanation , any code from any programming language is pretty much understandable for someone that knows at least one programming language.
@divyanshusingh600812 күн бұрын
Yup , thats why i dont even watch his pseuodo code , because i also consider this as a cheating
@ritikadhangar29792 ай бұрын
Sir I can't express my job while taking your lecture. before that I am scared of DSA but now I enjoy due to you thankyou so muchhh
@sundaramkumarsingh8448 Жыл бұрын
clear cut explanation. Thank you Striver
@zerobear-xf7qh3 ай бұрын
nice solution i dont think i would come up with this solution on my own
@cenacr007 Жыл бұрын
Array and Strings are the most important for interviews, please make a playlist on strings.
@ayushagarwal52714 ай бұрын
This man is a genius!
@tanvirkekan61118 ай бұрын
This is an interesting soln: x,y = 0, len(mat[0]) - 1 while x < len(mat) or y >= 0: if x + 1 < len(mat) and mat[x + 1][y] > mat[x][y]: x += 1 elif y - 1 >= 0 and mat[x][y - 1] > mat[x][y]: y -= 1 else: break return [x, y]
@TarunGautam-r7g2 ай бұрын
good
@abdulrehmanamer4252Ай бұрын
[ [13,10], [12,11] ] Your code fails on this testcase
@shwetachoudhary900322 күн бұрын
Sir plz complete this series🥺🥺 i have learned a lot from this series so plz don't leave me in middle🙏🏻🥺
@utkarshtrivedi98665 ай бұрын
Understood, even just looking at pseudo code, I was able to code it myself.
@LearnwithEase209 ай бұрын
please make videos on string and other topic it is much needed no one explains like you!🙂
@stith_pragya9 ай бұрын
Thank You Much for this wonderful video..........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@JothiprakashThangaraj4 ай бұрын
sudo code is sufficient for any developer to write code in any language , understood thanks a lot !!
@iammysterious-ud9cf Жыл бұрын
Please Start Linked Lists
@securelyinsaycure6 ай бұрын
Striver you are a godsend to so many of us! Thank you 🙏
@anonymous-ms2en5 ай бұрын
love you striver ,clear explaination
@jeehub041 Жыл бұрын
What an approach mind blown 🙌🙌
@harshit.537 ай бұрын
i don't understand why people complain about only using cpp...first of all he discusses the idea behind the code and then writes a simple pseudo code...secondly, even if he uses cpp, any good coder can easily convert that code into any other language, maybe in other languages the function name and syntax is different, so u just need to use the functions provided by ur language
@JagadeeswarN-ur7of13 күн бұрын
Great Explanation!! Thanks!!
@GeetainSaar3 ай бұрын
your skin glowing in whole video
@adilkevin62207 ай бұрын
ARTICLE column is empty for this problem. Please attach it.
@rahulgoel76528 ай бұрын
I am unsure if first method would have O(mn *4) TC. You are traversing the matrix once, i.e. O(mn). For each element, checking the neighbors is constant time, so it wont be 4 times the number of elements
@tusharyadav58743 ай бұрын
We will say it as O(m*n*4). So thats why he said we can we can slightly improve this by just finding the largest element in matrix . Then will be not using that 4 .
@rahulgoel76523 ай бұрын
@@tusharyadav5874 I am sorry but I didn't understand what you wrote.
@AshishSingh-he2qo4 ай бұрын
Understood 🎉🎉
@shivamdubey3798 Жыл бұрын
Bhaiya please video continue to upload Kara Karo mera ye week topic haa🙏🙏
@sidharthsharma341 Жыл бұрын
What are the upcoming topics?after this
@swagcoder Жыл бұрын
For this problem, in leetcode , it’ll fail one test case where there are multiple peaks in the same row, that one is different scenario though, in this problem it is assumed that there will be only one peak per row , because you can’t eliminate directly in case of multiple peaks.
@takeUforward Жыл бұрын
this works for it also, because even if it has multiple peaks, it will find ,watch the first video to understand why it works
@swagcoder Жыл бұрын
Thanks for replying Stiver, Understood
@vikassinghbisht73057 ай бұрын
striver you are just too good
@t3ch_r4id3 ай бұрын
class Solution { public: int maxElement(vector& arr,int n,int m, int col){ int index = -1; int maxele = INT_MIN; for (int i = 0; i < m; i++){ if(arr[i][col] > maxele){ maxele = arr[i][col]; index = i; } } return index; } vector findPeakGrid(vector& mat){ //n no of cloumns are there int n = mat.size();//size of each row //m no of rows are there int m = mat[0].size();//size of each column int low = 0, high = n - 1; while(low = 0)? mat[row][mid - 1] : -1; int right = (mid+1 < n)? mat[row][mid + 1] : -1; if(left < mat[row][mid] && mat[row][mid] > right){ return {row, mid}; } else if(left > mat[row][mid]){//cut out right part high = mid - 1; } else{//cut out the left part low = mid + 1; } } return {-1, -1}; } }; can anyone find the mistake please🙏 it's showing runtime error (something overflow) for a very large input matrix
@roshankoshy61413 ай бұрын
high = n - 1 it is high = m- 1
@AYUSHNIGAM97Ай бұрын
Can't we find the vertical peak with Binary search as well and reduce complexity to O(logn * logm)?
@ashish76042 ай бұрын
don't you think if we keep udpating ele with bigger ele found then it will take O(m+n) time better than current time comp
@anusmitahait2329 Жыл бұрын
Problem seemed so intimidating at the begining, later on was simple variation of peak.
@lokeshnegi5051Ай бұрын
even if you are writing the code in cpp what's wrong in that it's so easy nowadays to convert it to any language of your choice with so many AI tools, the main part is the intuition
@TheAI-Tutor4 ай бұрын
But instead of traversing vertically, can't we just Traverse horizontally and find the maximum element to do STL and then check for the upper and lower element? and discard the upper half/lower half then?
@NazeerBashaShaik7 ай бұрын
Understood, thank you.
@Fe-ironmanАй бұрын
finally didn't understood one of your videos lol....understood all of the rest in series one remaining tho
@chandandasari6351 Жыл бұрын
bro plzz make a videos on string problems it was missed in play list bro strivers a to Z sheet plzz upload videos
@MJBZG4 ай бұрын
didn't really understand but will try more
@vcfirefox13 күн бұрын
superb
@gugulothsrilakshmi872910 ай бұрын
written article not there in description
@VishalKumar-uk5uc Жыл бұрын
Ek month wait Kiya ek video ke liye
@learn_in_shorts Жыл бұрын
Bhaiya mey aapka binary tree ka playlist se tree padh rha hu but jab aap iss video mey jaise padhete hai to sab samjh aata hai but tree wala mey aisa kuch samjh nahi aa rha hai jab jab aap board pr padhye jab tak to sab samjh aaya but uske baad kuch jyada nahi aaya 😊 plz bhaiya aap iss video ki format mey videos banaya kariye plz and do something trees also
@DeadPoolx17123 ай бұрын
UNDERSTOOD;
@RitikaMajumdar__F9 ай бұрын
bhaiya the java cpp notes's link is not given in the description. Please do share it.
@ddevarapaga51344 ай бұрын
Understood brother
@SurajYadav-bt9jb4 ай бұрын
I have one doubt regarding BS that it can apply on sorted ones, but here 2D Matrix is not sorted so how can we apply BS on it , please resolve my confusion
@ranjeetkumaryadav29672 ай бұрын
bhaiya please upload article of this problem
@GeetainSaar3 ай бұрын
give its article also
@AbdulRehman-ee8zc Жыл бұрын
sir khan thay aap aap hi k lecture ka intizar tha
@VarshaSingh-hi2sb2 ай бұрын
Can there be a case where the part which have omitted peak element was present there and not where we are heading towards?
@brp35222 ай бұрын
11:35 This is the part that answers your question
@guttulavybhav10304 ай бұрын
striver please upload videos on strings it is difficult to go to others videos....
@sanketatmaram2 ай бұрын
understood!
@prikshit_sharma4071 Жыл бұрын
Bhaiya linkedlist start krdo iske badh
@Learnprogramming-q7f9 ай бұрын
Thank you Bhaiya
@mahimagautam1810 Жыл бұрын
class Solution { public int findMaxIndex(int[][] mat,int mid,int n) { int maxi = -1; int ind = -1; for (int i = 0; i < n; i++) { if (mat[i][mid] > maxi) { maxi = mat[i][mid]; ind = i; } } return ind; } public int[] findPeakGrid(int[][] mat) { int ans[] = {-1,-1}; int n = mat.length; int m = mat[0].length; int low =0; int high = m-1; while(low=0 ? mat[index][mid-1]:-1; int right = mid+1left && mat[index][mid]>right){ return new int[]{index, mid}; } else if (mat[index][mid]
@Harshitbejsbsksjnw4 ай бұрын
Just a little doubt, when you say we can find the maximum element in the matrix and it will surely be the peak as well. What about the fact that there can be two maximums in the matrix and both lie adjacent to each other? And the question says that the element should be strictly greater than its adjacents......
@ShanmugaSundaramS-o6i3 ай бұрын
same elements wont be adjacent to each other in question
@hashcodez7579 ай бұрын
Understood!!
@vishious149 ай бұрын
Understoood !!!!!
@saketjaiswalSJ Жыл бұрын
linked list striver bhaiya
@DeepakPatel-d5v6 ай бұрын
Thanks a lot Bhaiya
@amanpatel6203 Жыл бұрын
long awaited
@oyeesharme3 ай бұрын
thanks bhaiya
@daniyalhussain5231 Жыл бұрын
Solution in C++: class Solution { public: int findMaxIndex(vector&mat,int col,int rows) { int maxi=INT_MIN; int maxIndex; for(int i=0;imaxi) { maxi=mat[i][col]; maxIndex=i; } } return maxIndex; } vector findPeakGrid(vector& mat) { vectorans(2); int rows=mat.size(); int cols=mat[0].size(); int low=0,high=cols-1; while(low=0)left=mat[maxElementRowIndex][mid-1];//edge case int right=-1; if(mid+1left&&curr>right) { ans[0]=maxElementRowIndex; ans[1]=mid; return ans; } else if(curr
@viveksoni32696 ай бұрын
Very Nice!!!!
@nayankhuman10433 ай бұрын
Understood :)
@soumiyamuthuraj35164 ай бұрын
awesome
@anand_yv Жыл бұрын
Understood
@mithileshkumbhar79687 ай бұрын
Striver......The link to this problem on your page is not opening to view the code and intuition.
@lakshsinghania2 ай бұрын
bhaiya i did convert from 2d array to 1d array but only 45/55 test cases is passing pls help class Solution { public: vector findPeakGrid(vector& matrix) { // binary search on answer int m = matrix.size(); int n = matrix[0].size(); // tc = o(log(m*n)) int start = 0; // created an imaginery 1D array of size from 0 to n*m-1 int end = (n * m) - 1; while (start 0) ? matrix[i - 1][j] : -1; int bottom = (i < m - 1) ? matrix[i + 1][j] : -1; int left = (j > 0) ? matrix[i][j - 1] : -1; int right = (j < n - 1) ? matrix[i][j + 1] : -1; if (mid > start && mid < n * m - 1) { if (matrix[i][j] > top && matrix[i][j] > bottom && matrix[i][j] > left && matrix[i][j] > right) { return {i, j}; // Peak element found } // If left or top neighbor is greater, move to the left or top // half if (left > matrix[i][j] || top > matrix[i][j]) { end = mid - 1; } else { // Else move to the right or bottom half start = mid + 1; } } else if (mid == start) { // Only move right if there's no left neighbor if (matrix[i][j] > right && matrix[i][j] > bottom) { return {i, j}; } else { start = mid + 1; } } else if(mid == end){ // Only move left if there's no right neighbor if (matrix[i][j] > left && matrix[i][j] > top) { return {i, j}; } else { end = mid - 1; } } } return {-1, -1}; } };
@vijeshsshetty Жыл бұрын
linked list series plss
@surbhirathore._5 ай бұрын
Done!!!
@sanjayp.m70084 ай бұрын
why cant i use the logic of matching the row and col to mid and considering this matrix as a 2d array. i tried this but only 46 testcases passed in the leetcode qn. class Solution { public: vector findPeakGrid(vector& mat) { int n = mat.size(); int m = mat[0].size(); int low = 0; int high = n * m - 1; while (low = 0) ? mat[row][col - 1] : INT_MIN; int bottom = (row + 1 < n) ? mat[row + 1][col] : INT_MIN; int top = (row - 1 >= 0) ? mat[row - 1][col] : INT_MIN; if (el > right && el > left && el > top && el > bottom) { return {row, col}; } if (right > el) { low = mid + 1; } else if (left > el) { high = mid - 1; } else if (bottom > el) { low = mid + 1; } else { high = mid - 1; } } return {-1, -1}; } };
public class solution { public static int []find Peek Grid(int [][]grid){ int n=grid. length,m=grid [0].length; int l=0,r=m-1; while (lgrid [idx][mid +1]){ r=mid; }else { l=mid-1; } return new int []{l,find max(grid [l])}; } public static int find max(int []col){ int index =0,n=col length; for(int i=0;icol[index]) index =i; } return index; } }; 🎉❤
@Lucifer0872 Жыл бұрын
Biltu kaka Zindabad
@AvaneeshSrivastava-lm5vj Жыл бұрын
understood. thank you. you should sleep a bit more.
@RAJPATEL-ir7ly5 ай бұрын
O(n+m) BFS class Solution { public: vector findPeakGrid(vector& mat) { int i = 0 ; int j = 0 ; int n = mat.size() ; int m = mat[0].size() ; while(true){ int flag = 0 ; vector coordinates = {{1,0} , {0,1} , {-1,0} , {0,-1}} ; int maxi= -1 ; int newRow =0 ; int newCol = 0 ; for(auto coordinate : coordinates){ int x = i+coordinate.first ; int y = j+coordinate.second ; if(x>=0 && y>=0 && x
@cenacr007 Жыл бұрын
us
@adityauditsingh5986 Жыл бұрын
first view xD
@ishangujarathi10 Жыл бұрын
why am i getting a runtime error when i submit the solution on leetcode? @striver??
@ajithc5505 Жыл бұрын
int left = mid-1>=0 ? mat[index][mid-1]:-1; int right = mid+1
@tejaswaniguttula59617 ай бұрын
@@ajithc5505 Hi vector findPeakGrid(vector &g){ // Write your code here. int rows = g.size(); int cols = g[0].size(); int low = 0, high = cols-1; while(low max_ele){ max_ele = g[i][mid]; index = i; } } int left = mid-1 >= 0 ? g[index][mid-1] : -1; int right = mid +1 < cols ? g[index][mid+1] : -1; if(max_ele > left && max_ele > right){ return {index, mid}; } else if(max_ele < g[index][mid-1]){ high = mid-1; } else{ low = mid+1; } } return {-1, -1}; } }; Though I applied edge cases why I am getting runtime error for this testcase?? Test case: [[10,50,40,30,20],[1,500,2,3,4]]