Lesson 24 of 34

Characters மற்றும் ASCIICharacters and ASCII

9 min 30 XP

ஒவ்வொரு char-க்கும் ஒரு எண் மதிப்பு (ASCII/Unicode) உண்டு: 'A' = 65, 'a' = 97, '0' = 48. ஆகவே char-களுடன் கணக்கிடலாம்: 'a' + 1 = 'b'.

Every char has a number (its ASCII/Unicode code): 'A' = 65, 'a' = 97, '0' = 48. So you can do maths with chars: 'a' + 1 is 'b'.

Example: edit me and press Run

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

எழுத்துகளின் எண்ணிக்கையை (frequency) எண்ண 26 அளவுள்ள int array பயன்படுத்தலாம்: count[ch - 'a']++. Anagram, முதல் repeat ஆகாத எழுத்து போன்ற கேள்விகளுக்கு இதுவே வழி.

Count letter frequencies with an int array of size 26: count[ch - 'a']++. This trick solves anagram and first-non-repeating-character questions.

Example: edit me and press Run

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

Challenge

+30 XP

small letters மட்டும் உள்ள இரண்டு சொற்களைப் படித்து, அவை anagram ஆக இருந்தால் (ஒரே எழுத்துகள், ஒரே எண்ணிக்கை) "Anagram", இல்லையெனில் "Not anagram" என்று print செய்யுங்கள். Input: listen silent → Output: Anagram

Read two lowercase words. Print "Anagram" if they use exactly the same letters the same number of times, otherwise "Not anagram". Input: listen silent → Output: Anagram

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