Skip to content

refactor: added comments for understanding the question better around array being sorted and not allowing duplicates#11

Open
vivek12345 wants to merge 2 commits intoyoung:masterfrom
vivek12345:fix-shared-numbers-problem
Open

refactor: added comments for understanding the question better around array being sorted and not allowing duplicates#11
vivek12345 wants to merge 2 commits intoyoung:masterfrom
vivek12345:fix-shared-numbers-problem

Conversation

@vivek12345
Copy link
Copy Markdown

@vivek12345 vivek12345 commented Jun 25, 2021

Issue
#12

What is the current behavior?

  • In the current question for shared numbers, we do not explicitly mention that the array is sorted and that it won't contain duplicate elements.
  • The answer to the solution increments only the xIterator but it should be incrementing the yIterator too since both values were same.
    This is important for scenario with duplicate values. For example
const x = [4, 4, 8, 9, 9];
const y = [4, 5, 9]

In the above problem technically the output should be [4, 9] but in the current implementation it will be [4, 4, 9]

What is the new behavior?

  • In this PR, I have refactored the question to include information around array being sorted and not containing duplicates.
  • In this PR, I have also added a fix to the answer where increment both x and y pointers when values are same.

Checklist:

  • Documentation
  • Tests N/A
  • Ready to be merged

… array being sorted and not allowing duplicates. Also fixed the solution
@vivek12345 vivek12345 changed the title refactor: added comments for understanding the question better around array being sorted and not allowing duplicates. Also fixed the solution refactor: added comments for understanding the question better around array being sorted and not allowing duplicates Jun 25, 2021
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.

1 participant