Check if the word can be formed with other letters respecting the order - Java Quiz Question



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.
}
}