Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:add two pointer algorithm #1207

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Harshdev098
Copy link
Contributor

No description provided.

Copy link

Visit the preview URL for this PR (for commit dd01e8e):

https://cp-algorithms--preview-1207-1ftu0mhq.web.app

(expires 2023-12-18T12:06:43.474286555Z)

Copy link

Visit the preview URL for this PR (for commit 77906fb):

https://cp-algorithms--preview-1207-1ftu0mhq.web.app

(expires 2023-12-18T12:19:11.016074097Z)

Copy link

Visit the preview URL for this PR (for commit 00c7ee0):

https://cp-algorithms--preview-1207-1ftu0mhq.web.app

(expires 2023-12-23T10:45:44.193696310Z)

Copy link

Visit the preview URL for this PR (for commit 3fb8ecc):

https://cp-algorithms--preview-1207-1ftu0mhq.web.app

(expires 2023-12-23T14:08:43.870563390Z)

Copy link

Visit the preview URL for this PR (for commit 00c7ee0):

https://cp-algorithms--preview-1207-1ftu0mhq.web.app

(expires 2023-12-23T14:14:03.094310265Z)

@mhayter
Copy link
Contributor

mhayter commented Dec 17, 2023

I'm not a maintainer, but don't forget: when creating a new article, modify the navigation.md and README.md.

How to contribute:
https://cp-algorithms.com/contrib.html

Copy link
Contributor

@fffelix-huang fffelix-huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The structure of the page is good, however I believe you are missing a lot of details. I don't think this is specific enough for someone new to 2-pointers.


## Example

### Two Sum Problem
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to put problem description here, or problem link for practice.


## Basic Idea

The basic idea behind the Two Pointer Algorithm is to maintain two pointers that traverse the data structure in a way that reduces the time complexity. The pointers move towards each other or in a specific pattern based on the problem requirements.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to mention that two pointers doesn't overlap, and hence it is at most $O(n)$ to traverse the whole array.

4. **Repeat:**
- Repeat steps 2 and 3 until the pointers meet or fulfill the problem requirements.

## Common Use Cases
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please give specific details on how you use 2-pointers to solve each of the followings. You should assume people who are reading this doesn't know how 2-pointers works beforehand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants