I was able to solve this task only when I changed the last names (map keys), so they were all different from each other.
So why does the task ask to check if people have the same last name, if for the last name to be the same, the key must also be the same?
I'm really confused here.
Does somebody know why?
Thanks!
If the KEY must be unique, why does it ask to check if people have the same last name (which is the key)?
Under discussion
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
Gellert Varga
11 May 2020, 19:03useful
Hi again!:)
Yes, the last names (map keys) MUST BE different from each other in a HashMap.
It's absoutely sure.
I wondered too, why the task asks for this.
The reason is in my opinion:
I think, this is only a tricky task.
The purpose: that this important HashMap-property is just better fixed in our brains while solving this task...
In the case of lastnames, I put only this test into the method:
to check the current lastname be found in the list or not.
I wrote the getSameLastNameCount() method like this:
my method can return only zero or 1! There is no other option in my method. And the task verifier accepted it!
+1
Henrique
11 May 2020, 20:13
Hey there, my Hungarian friend!
Yeah... that's a good guess. I was wondering if the person who made this task designed it to be tricky, or if it was not so well written.
Anyway, the first thing I always think is: "I'm probably missing something here" haha.
Thanks for your contribution!
0
Gellert Varga
11 May 2020, 21:08
You're welcome, my friend!:)
- Sometimes the authors made typo errors... And sometimes the language is the problem.
- Yes, i'm a hungarian:) but i am undetermined where are You from. The Google gives me two results for São Paulo: 1)Brasilia 2)Portugal.
+1
Henrique
11 May 2020, 21:34
I'm in São Paulo, a city in the state of São Paulo, in Brazil. So my primary language is Portuguese.
:D
0
Gellert Varga
11 May 2020, 22:14
OK, thanks:)
0