requirement: return sorted, no dup integer array. return size 0 array if no common found.
I have implemented in the following way:
1. create a third array to store common int . set size to max(array a, array b)
2. sort both array by quicksort
3. user for loop to find common value and store to third loop
4. fix integer 0 problem. when int array is initialize it put 0 . So I need to fix this
5. eliminate dup by run a for loop
This is definitely not the best way in term of time complexity. Can anyone provide better solution ?
I have implemented in the following way:
1. create a third array to store common int . set size to max(array a, array b)
2. sort both array by quicksort
3. user for loop to find common value and store to third loop
4. fix integer 0 problem. when int array is initialize it put 0 . So I need to fix this
5. eliminate dup by run a for loop
This is definitely not the best way in term of time complexity. Can anyone provide better solution ?