frontend-interviewing
frontend-interviewing copied to clipboard
refactor: added comments for understanding the question better around array being sorted and not allowing duplicates
Issue https://github.com/young/frontend-interviewing/issues/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 theyIterator
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
andy
pointers when values are same.
Checklist:
- [x] Documentation
- [ ] Tests N/A
- [x] Ready to be merged