in Education by
icse class 10 students plzz answer this write a program to check two words are in anagram (anagram is set of two words where they have same number of letters and even same letters in interchanged order) eg: WOLF FLOW here there are same 4 letters and even the letters are same Select the correct answer from above options

1 Answer

0 votes
by
// JAVA program to check whether two strings // are anagrams of each other import java.io.*; import java.util.*; class GFG { /* function to check whether two strings are anagram of each other */ static boolean areAnagram(char[] str1, char[] str2) { // Get lenghts of both strings int n1 = str1.length; int n2 = str2.length; // If length of both strings is not same, // then they cannot be anagram if (n1 != n2) return false; // Sort both strings Arrays.sort(str1); Arrays.sort(str2); // Compare sorted strings for (int i = 0; i < n1; i++) if (str1[i] != str2[i]) return false; return true; } /* Driver program to test to print printDups*/ public static void main(String args[]) { char str1[] = { ‘t’, ‘e’, ‘s’, ‘t’ }; char str2[] = { ‘t’, ‘t’, ‘e’, ‘w’ }; if (areAnagram(str1, str2)) System.out.println(“The two strings are” + ” anagram of each other”); else System.out.println(“The two strings are not” + ” anagram of each other”); } }

Related questions

0 votes
    icse class 10 students plzz answer this write a program to check two words are in anagram (anagram is set of ... the letters are same Select the correct answer from above options...
asked Dec 18, 2021 in Education by JackTerrance
0 votes
    write a program to enter a sentence and check if it contains palindrome words or not. if yes then count and ... present. Java class 10 Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    Write a program to input name and percentage of 20 students of class X in two separate one dimensional arrays. ... of the class. Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    What are the 5 functions or features of headphones?? plzz answer me and give me atleast 5 to 6 not only 1 ... waiting for your answer Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    Class 10 ICSE Computer Applications -What is static binding? No spam plz Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    i want the answers of understanding computer applications with blue J icse class 10 of chapter 4 Q23 Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    hi friends hope you all are doing great Plz answer my question please do not give invalid answers Write a program ... number. Thank you Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    Plzz give me solution of ch 1 number system of it apps class 7 . Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    writing related answer but in own words, can get the marks in 12th I. T online examination 2019? Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    Anyone can send me their computer exam paper (class 9th icse) Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    explain two type of low level language ? for class 5 short answer Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    Write a Java program to read two strings from command line arguments and check the equality of two strings using string function. Select the correct answer from above options...
asked Dec 9, 2021 in Education by JackTerrance
0 votes
    C program to count number of words in a sentence including comma tabs Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    a program to keep a track of students record and their marks according to the performance in the exam.. Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    Complete the sentence by choosing TWO WORDS either of which will fit the blank. The two words must both produce a ... on his bike. Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
...