Menu
Question Index
...


Write a program to check if the word can be formed with letters of the other word respecting the order. Can not use the letter more number of times than it is present in the original.

Input (String, String) Output (boolean)
dasavatharam, avatar true
dasavatharam, dasara true
dasavatharam, vasantham false
potato, pot true
potato, top false
heat, eat true
heat, hate false

class CanWordBeFormedRespectingTheOrder

{    public static void main(String s[])
    {
        String originalWord = "potato";
        System.out.println("The word 'pot' is present : " + canFormWord(originalWord, "pot"));

    }


public static boolean canFormWord(String originalWord, String formedWord) {
//Write code here to identify if the word can be formed with letters of the other word respecting the order. Can not use the letter more number of times than it is present in the original word.
}
}

Doubts

Problems

Topic: Java Searching Strings - Java indexOf, lastIndexOf Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App