DSA icon indicating copy to clipboard operation
DSA copied to clipboard

chore(CPlusPlus): Merge two sorted array - Special Manner

Open prateek-narsinghani opened this issue 2 years ago • 3 comments

PR Checklist:

  • [x] My submission is formatted according to the guidelines in the contributing guide
  • [x] My addition is on refer on the language README.md file
  • [x] My addition does not have a spelling problem
  • [x] My submission has a proper and user-friendly description of the algorithm
  • [x] My submission has the time complexity of the algorithm
  • [x] My submission has sample input-output of the program (NOT FOR PYTHON)

What kind of change does this PR introduce? (check at least one)

  • [ ] Bugfix
  • [x] New algorithm
  • [ ] Optimization in previous algorithms
  • [ ] Code style update
  • [ ] Refactor
  • [ ] Documentation
  • [ ] Other, please describe:

Briefly describe the changes in this PR

Merge two sorted array - Special Manner You're given two sorted arrays. You have to merge them in this manner that if there are some same elements in both of them the third merging array should have less number of same elements

Other information:

Time Complexity: O(len_arr1 + len_arr2) (since we are iterating over all the elements of both arrays) Space Complexity: O(len_arr1 + len_arr2)

prateek-narsinghani avatar Oct 25 '23 18:10 prateek-narsinghani

Thanks for opening this pull request! Please check out our contributing guidelines.

welcome[bot] avatar Oct 25 '23 18:10 welcome[bot]

@Arsenic-ATG @UG-SEP @aayushjain7 @Ashborn-SM @Ashad001 @ayo-ajayi @ming-tsai please have a look at this since I am new to open source please let me know if I have missed anything.

This is related to Issue: https://github.com/MakeContributions/DSA/issues/1272

prateek-narsinghani avatar Oct 25 '23 19:10 prateek-narsinghani

@hamzamehmood67 Time complexity for my approach is O(m+n) where m, n are size of arrays, the if conditions will not have much impact on the performance of the code

prateek-narsinghani avatar Oct 26 '23 09:10 prateek-narsinghani