Lesson 32 of 34

HashMap: Key-Value சேமிப்பு

10 min 35 XP

HashMap ஒவ்வொரு key-க்கும் ஒரு value சேமிக்கும், அகராதி போல. Key மூலம் value-ஐ மிக வேகமாகப் பெறலாம். Key-கள் தனித்துவமானவை; அதே 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). வரிசை முக்கியமெனில் TreeMap (sorted keys) பயன்படுத்துங்கள்.

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

small letters சொல் ஒன்றைப் படித்து, முதன்முதலில் ஒரு முறை மட்டுமே வரும் எழுத்தை print செய்யுங்கள். அப்படி எதுவும் இல்லையெனில் -1 print செய்யுங்கள். Input: swiss → Output: w

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