8 kyu
Merge two sorted arrays into one
24,128 of 39,100Y.y
Description:
You are given two sorted arrays that contain only integers. These arrays may be sorted in either ascending or descending order. Your task is to merge them into a single array, ensuring that:
The resulting array is sorted in ascending order.
Any duplicate values are removed, so each integer appears only once.
If both input arrays are empty, return an empty array.
No input validation is needed, as both arrays are guaranteed to contain zero or more integers.
Examples (input -> output)
* [1, 2, 3, 4, 5], [6, 7, 8, 9, 10] -> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
* [1, 3, 5, 7, 9], [10, 8, 6, 4, 2] -> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
* [1, 3, 5, 7, 9, 11, 12], [1, 2, 3, 4, 5, 10, 12] -> [1, 2, 3, 4, 5, 7, 9, 10, 11, 12]
Happy coding!
Fundamentals
Arrays
Similar Kata:
Stats:
Created | Feb 7, 2017 |
Published | Feb 7, 2017 |
Warriors Trained | 52490 |
Total Skips | 2213 |
Total Code Submissions | 114971 |
Total Times Completed | 39100 |
JavaScript Completions | 24128 |
Python Completions | 12416 |
Ruby Completions | 996 |
COBOL Completions | 11 |
C# Completions | 817 |
D Completions | 16 |
Rust Completions | 446 |
Go Completions | 814 |
Scala Completions | 43 |
CoffeeScript Completions | 11 |
Prolog Completions | 12 |
Total Stars | 390 |
% of votes with a positive feedback rating | 93% of 3382 |
Total "Very Satisfied" Votes | 2948 |
Total "Somewhat Satisfied" Votes | 362 |
Total "Not Satisfied" Votes | 72 |
Total Rank Assessments | 113 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 1 kyu |
Lowest Assessed Rank | 8 kyu |