Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Interview question - better solution for MergePurgeAndReverseOrder() Date: Fri, 29 Mar 2019 11:19:50 -0400 Organization: A noiseless patient Spider Lines: 27 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 29 Mar 2019 15:19:52 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="a009d1dd14e8bc9b605bfd47bc686a7d"; logging-data="32601"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/r8xusLBwHHBGm7eNytJth" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 Cancel-Lock: sha1:+lUuI9bzQDIMWC0PLeXF8wVCG38= In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:38825 On 3/29/2019 11:01 AM, Graeme Geldenhuys wrote: > Hi, > > I recently attended a Java developer interview and had to implement the > MergePurgeAndReverseSort() method. I managed to complete it and > afterwards wrote some unit tests to confirm that it works. But is there > a better way to implement it, or did I do an okay job about it. > > I can post the unit tests too if that might help. > > Any feedback would be very much appreciated. > > [Code snipped; see up-thread] Looks pretty much okay, although it could be tightened a bit. Most of the opportunities for tightening come down to matters of taste, but one that stands out (to me, anyway) is the matter of moving all the Integers into a single array merely to move them again into a Set -- Why not just pop 'em into the Set right away? I personally would have written the rest somewhat differently than you did, but the differences don't seem important. Matters of taste, as I wrote earlier. -- esosman@comcast-dot-net.invalid Six hundred sixty-three days to go.