We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
To answer your question let's suppose you take CAT and TAC as input;
Now in the 1st for loop the total occurrence of each character of the given input has been subtracted by the integer array defined i.e c[] & d[];
If it's not an anagram then the value of c[] at ith occurrence would not be similar to d[] at the same ith occurrence.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Anagrams
You are viewing a single comment's thread. Return to all comments →
To answer your question let's suppose you take CAT and TAC as input; Now in the 1st for loop the total occurrence of each character of the given input has been subtracted by the integer array defined i.e c[] & d[]; If it's not an anagram then the value of c[] at ith occurrence would not be similar to d[] at the same ith occurrence.