id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

simona1@sfusd.edu > mergeChars
prev  |  next  |  chance

BROKEN! NOT WORKING! (There seems to be a problem with char arrays in codingbat) Start with two arrays of chars, a and b, each with its elements in alphabetical order and without duplicates. Return a new array containing the first n elements from the two arrays. The result array should be in alphabetical order and without duplicates. a and b will both have a length which is n or more. The best "linear" solution makes a single pass over A and B, taking advantage of the fact that they are in alphabetical order, copying elements directly to the new array.


mergeChars(["a", "c", "e", "g"], ["b", "d", "f", "h"], 4) → ["a", "b", "c", "d"]
mergeChars(["a", "c", "z"], ["b", "f", "z"], 3) → ["a", "b", "c"]
mergeChars(["a", "c", "z"], ["c", "f", "z"], 3) → ["a", "c", "c"]

...Save, Compile, Run (ctrl-enter)

public char[] mergeChars(char[] a, char[] b, int n) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 401

Copyright Nick Parlante 2017 - privacy