Two pointers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Two pointers

Can someone explain “Two pointers” technique (Easy to understand)? How do you use ? In Python or Java.

8th Oct 2023, 10:35 AM
āļ™āļĪāļŠāļĢāļ“āđŒ āļ­āļĢāļīāļĒāļŠāļāļļāļĨāļ§āļ‡āļĻāđŒ
āļ™āļĪāļŠāļĢāļ“āđŒ āļ­āļĢāļīāļĒāļŠāļāļļāļĨāļ§āļ‡āļĻāđŒ - avatar
1 Answer
0
example find two numbers from array whose sum is target number n + m = target if found return true pointer1 points to n pointer2 points to m in array, pointer means array index array is sorted generally: find value(s) in a datastructure which meets the condition and use two pointers rather than one
8th Oct 2023, 3:58 PM
zemiak