Menu
Topics Index
...
`

Check If The Words Are Jumble Of Each Other Having Duplicates


If you need explanation Read this topic

If you need Answer Take test on this topic

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[])
        {
        }

}
Topic: Learn Arrays And Loops

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

here we need to check the every char in the 1st array must present in the array2 than we can return true
* start for loop to check the chars in the array1(i=0;i<array1.length;I++)
*start inner for loop to check the array2 j=0;j<array2.length;j++
* check if the array[i]==array[j] than mak flag=true and replace that char in array2 with some other char array2[j]='*'; and come out of the loop(break the loop)
* after coming out of the inner loop check if the flag is true than mak res=true else return false bcz if one char is missing means we can't form the word
* for every iteration makes flag=false;
*finally after coming out of the loops return the res

Posted by Uday Kumar    2015-02-24 08:57:17


here we have to find jumble words.....for this we have to chek that every character of first array should be present in another array..... if this satisfies then return true otherwise false...... take p=true.... take a loop a=0 to array1.length { char ch=array1[a] ...take anothr loop... b=0 to array2.length { if array[2]!=char i. e the char is not present in another array...  den p=false break }} return p

Posted by Asma Mujtaba Khan    2015-02-24 09:51:27


This dose is now closed and the winners are . The 'lucky liker' is Sai Ram. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2015-02-25 02:46:28


© meritcampus 2019

All Rights Reserved.

Open In App