Lesson 32 of 34

HashMap: Key-Value സംഭരണം

10 min 35 XP

HashMap ഒരു നിഘണ്ടു പോലെ ഓരോ key-ക്കും ഒരു value സൂക്ഷിക്കുന്നു, key ഉപയോഗിച്ച് value വളരെ വേഗത്തിൽ കണ്ടെത്തുന്നു. Keys അദ്വിതീയമാണ്: അതേ key വീണ്ടും put ചെയ്താൽ അതിന്റെ value മാറും.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

എണ്ണൽ ആണ് HashMap-ന്റെ ക്ലാസിക് ഉപയോഗം: map.put(w, map.getOrDefault(w, 0) + 1). Keys sorted ക്രമത്തിൽ വേണമെങ്കിൽ TreeMap ഉപയോഗിക്കൂ.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Challenge

+35 XP

ഒരു lowercase വാക്ക് വായിച്ച്, ഒരു തവണ മാത്രം വരുന്ന ആദ്യ അക്ഷരം print ചെയ്യൂ. അങ്ങനെയൊന്നില്ലെങ്കിൽ -1 print ചെയ്യൂ. Input: swiss → Output: w

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.