MultiplePointersPattern

Multiple pointers algorithm pattern

Using the multiple pointers pattern by creating pointers or values that correspond to an index or position and move towards the start end or middle based on a condition can help you efficiently solve problems with minimal space complexity.

usually, you use it if you’re searching for a pair of values or a condition, you start at two places and you work your way to each other in order to reach a middle value.

an example of this is if you were asked to find a pair of numbers that add up to something in particular. assuming the array of integers that you’re given is sorted, you can start a pointer at index 0 and -1, from here you could iterate each index on pointer 1 until you reach the second pointer, from there you can iterate down on pointer 2 until you get the pair that returns the sum you’re looking for if there is no answer for this problem you can return null.

--

--

--

Software engineer, Graduate of Flatiron school. Currently volunteering! Looking to talk to fellow engineers, please send me a message!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Bingbon Integrates Binance API Services for Copy Trading

OTO Protocol Fair Launch Announcement

In this post we will go through the steps for working within GitHub on a Linux Server.

Smart Phone Controlled Home Automation using Raspberry Pi and BleuIO

Tungsten Hackathon: All Systems Go for Developer Network Launch

Best of Level Up Coding (October 2020)

Publishing Tekton Resources as bundles on OCI registry

[LeetCode][python3]Day04. Move Zeroes (30-Day LeetCoding Challenge)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Angelo Poole

Angelo Poole

Software engineer, Graduate of Flatiron school. Currently volunteering! Looking to talk to fellow engineers, please send me a message!

More from Medium

What is TypeScript and Why Should You Use it?

<vanilla javascript> TO DO LIST

Debouncing in JavaScript

The Top 5 JavaScript ES12 Features to Try Right Now

The Top 5 JavaScript ES12 Features to Try Right Now