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.