Technique #3: Use the fact that an anagrams have the same number sum of distinct of letters in each word. Given that, wr

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Technique #3: Use the fact that an anagrams have the same number sum of distinct of letters in each word. Given that, wr

Post by answerhappygod »

Technique 3 Use The Fact That An Anagrams Have The Same Number Sum Of Distinct Of Letters In Each Word Given That Wr 1
Technique 3 Use The Fact That An Anagrams Have The Same Number Sum Of Distinct Of Letters In Each Word Given That Wr 1 (70.75 KiB) Viewed 60 times
Technique #3: Use the fact that an anagrams have the same number sum of distinct of letters in each word. Given that, write an algorithm to compare if two words are anagrams of each other by comparing the sum of distinct letters. So, for anagrams Stressed Desserts the sum for each charecter is: = d = 1 e = 2 r = 1 s = 3 words that are anagrams of eachother have the same sum for each distinct character. hint: you can use an array to hold the sums of individual characters then index into the sum using the ascii value of a character. Using the example above of "Stressed" we know the asci value for 'd' is 100. So to increment the amount of d's we observe in an array we can do A[100] = +1; or A[asci(d)] = +1;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply