Kevin Mckeon wrote:Given a LinkedHashSet of anagrams, print each set of anagrams alphabetically and on a new line.
...
I am trying to traverse my LinkedHashSet to give the following output :
lamp palm
finger fringe
elbow below bowel
There are three kinds of actuaries: those who can count, and those who can't.
Dave Tolls wrote:and then ordered alphabetically
output example wrote:elbow below bowel
Kevin Mckeon wrote:Any tips or ideas ?
Kevin Mckeon wrote:I cant see how this output is possible
Liutauras Vilda wrote:
Dave Tolls wrote:and then ordered alphabetically
output example wrote:elbow below bowel
Alphabetically supposed to be: below, bowel, elbow
Liutauras Vilda wrote:Looking to Piet's tip (missed it before), I must say I like it too. I have solution ready.
@OP
I really advise to follow Piet's suggestion, certainly easier approach than I had initially in my mind.
Anyway, go small.
First thing is to figure out how to normalize string/anagram. There is a habitual approach or using streams. As for habitual, think if you could convert string to an array of(?) and use Collections class to sort it? So later you could construct back the string from sorted array. Using streams api is slightly easier.
No, I don't think it is too difficult. You would need ive minutes to think about the question and it should be possible to complete those questions in the 1½ hours. The two programming questions are actually similar.Kevin Mckeon wrote:. . . would this question be considered a difficult interview question ? . . .
Kevin Mckeon wrote:On a side note, would this question be considered a difficult interview question ?
Kevin Mckeon wrote:Personally I felt this was difficult but maybe I am underestimating the Java developer required skill level.
Requirements wrote:Given a LinkedHashSet of anagrams
Kevin Mckeon wrote:In the end I had to settle for a similar method which is far from short
There are three kinds of actuaries: those who can count, and those who can't.
I prefer the slighlty more java-8-esq approach using computeIfAbsent().Liutauras Vilda wrote:
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:@Kevin
we've been throwing quite some violence at you! So have a cow,
There are three kinds of actuaries: those who can count, and those who can't.
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|