Lesson 24 of 34

Characters आणि ASCII

9 min 30 XP

प्रत्येक char ला एक संख्या असते (त्याचा ASCII/Unicode code): 'A' = 65, 'a' = 97, '0' = 48. म्हणून chars सोबत गणित करता येते: 'a' + 1 म्हणजे 'b'.

Example: edit me and press Run

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

26 size च्या int array ने अक्षरांची frequency मोजा: count[ch - 'a']++. ही trick anagram आणि first-non-repeating-character प्रश्न सोडवते.

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

दोन lowercase शब्द वाचा. दोन्हीमध्ये अगदी तीच अक्षरे तितक्याच वेळा असतील तर "Anagram", नाहीतर "Not anagram" print करा. Input: listen silent → Output: Anagram

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