ZoranPandovski / al-go-rithms

:musical_note: Algorithms written in different programming languages - https://zoranpandovski.github.io/al-go-rithms/
Creative Commons Zero v1.0 Universal
1.33k stars 1.95k forks source link

Two pointer technique #3461

Open theshoonyam opened 1 year ago

theshoonyam commented 1 year ago

Two pointer technique is used to find two numbers from the given array whose sum is given. This Algorithm search the two number in n*log(n) time while brute force method does the same in n-square time. Since this algorithm is more efficient, it is more widely used in Competitive programming. If the given array is sorted it will take time of order n i.e. the size of input array.