Skip to content

Remove Element Pull Request #127

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

Merged
merged 2 commits into from
Oct 27, 2020
Merged

Remove Element Pull Request #127

merged 2 commits into from
Oct 27, 2020

Conversation

HoangJames
Copy link
Contributor

@HoangJames HoangJames commented Oct 26, 2020

Pull Request Template

Description

Given an array nums and a value val, remove all instances of that value in-place and return the new length.

Approach involves using two pointers (fast and slow). Iterate through the array with the fast pointer, if the value at fast does not match the value, then we just need to swap value of the slow pointer with the fast pointer. We can then increment slow pointer after each swap (fast pointer is incremented after each iteration). At the end, the array is modified in place and effectively all occurrences of the 'value' is moved to the end of the array. The value of 'slow' gives the length of the modified array where there are no occurrences of 'value'.

Put check marks:

Have you made changes in README file ?

  • Added problem & solution under correct topic.
  • Specified Space & Time complexity.
  • Specified difficulty level, tag & Note(if any).

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.

  • Test A
  • Test B
    Accepted Solution on LeetCode

Make sure all below guidelines are followed else PR will get Reject:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code so that it is easy to understand
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@welcome
Copy link

welcome bot commented Oct 26, 2020

I can tell this is your first pull request! Thank you I'm so honored. 🎉🎉🎉 I'll take a look at it ASAP!

@GouravRusiya30 GouravRusiya30 merged commit 8f375e4 into codedecks-in:master Oct 27, 2020
@welcome
Copy link

welcome bot commented Oct 27, 2020

Your code looks great! Congrats, I've gone ahead and merged your first pull request! Keep it up! alt text

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.

2 participants