Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
can I use 2 pointers also?

saurabh28jaiswal

Mar 26, 2024

it seems we are calculating difference of 2 pointers in array, so can I use 2 pointer mechanism? however array is not sorted?

0

0

Comments
Comments
SHLOK KOTHARI
SHLOK KOTHARI2 years ago

I guess we are inherently using two pointers, but with stacks. At each element we visit, if it is greater than previous one, we move the second pointer to visit all of the previous ones.

I would like to think that it is not the traditional horizontal movement of two po...

On this page