Find if a word in the character arrays are jumble word of the other, having duplicate letters.
Input (Char Array1, Array2) | Output |
---|---|
{ 'h', 'e', 'l', 'l', 'o' }, { 'h', 'e', 'l', 'l', 'o' } | true |
{ 'b', 'a', 'n', 'a', 'n', 'a' }, { 'a', 'n', 'a', 'n', 'a', 'b' } | true |
{ 't', 's', 's', 't' } , { 'v', 'q', 't', 's' } | false |
{ 'h', 'e', 'i', 'g', 'h', 't' }, { 'h', 'e', 'i', 'g', 't'} | false |
{ 'h', 'e', 'l', 'l', 'o' }, { 'h', 'e', 'l', 'l', 'l' } | false |
class IsJumbled
{ public static void main(String s[])
{
char inputArray1[] = {'h', 'e', 'l', 'l', 'o'};
char inputArray2[] = {'h', 'e', 'l', 'l', 'o'};
System.out.println("Is \"hello\" a jumble of \"hello\" : " + isJumbled(inputArray1, inputArray2));
}
public static boolean isJumbled(char array1[], char array2[])
{
//Write a code here to check the words are jumble of each other or not and return it.
}
}
Topic: Learn Arrays And Loops