Piet Souris wrote:
Simon Ritchie wrote:I'm finding much of it difficult to follow as I'm not anywhere near proficient on streams or lambdas but it's given me something to work on.
Liutauras Vilda wrote:
Simon Ritchie wrote:I was looking at the Collectors API for the toMap() method but I can't see an example there that takes four parameters.
"Get every key and value in this Map, then map the key value onto a parameter called k, then return the results in a LinkedHashMap object"
Carey Brown wrote:I took your various solutions, along with my non-Java8 version, and I'm getting inconsistent results. ...
Re-reading the OP's post:
Liutauras Vilda wrote:Because I retrieve nth frequency (value) instead of the key. You can verify that by looking to my answer, which is the frequency of 4.
Carey Brown wrote:He says "element" not frequency. I take that to mean the key not the value.
salvin francis wrote:To get the 4th rarest, I guess it would have to be sorted as per occurrence rate ascending:
1=1, -> 1st (most) rarest
5=1, -> 2nd rarest
3=3, -> 3rd rarest
6=3, -> 4th rarest
7=4, -> 5th rarest
2=5, -> 6th rarest
4=5 -> 7th (least) rarest
salvin francis wrote:There's a tiny bug in the code...
Liutauras Vilda wrote:salvin, I like how we programmers are so protective about our code.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your databasehttps://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database