Menu
Question Index
...


Write a program to find smallest substring in a string which contains all characters of another string
Note: The characters may be present any where in the resultant string.

Input (String, String) Output (String)
ABCDGALYDNVC, AD DGA
KNNBJAHBJGLAJUYN, BAN NBJA
FLMOJLOFL, LOL LOFL
HEDGGJDLE, DGE EDG

class GetSmallestSubString

{    public static void main(String s[])
    {
        String stringOne = "ABCDDBECA", stringTwo = "ACD";
        System.out.println("Minimum substring in " + stringOne + " which contains all the characters of " + stringTwo + " is " + getSmallestSubstring(stringOne, stringTwo));

    }


public static String getSmallestSubstring(String input, String required) {
//Write code here to get the smallest substring which contains all characters of another string
}

//If required, write any additional methods here
}

Doubts

Problems

Topic: Java String substring() method - substring In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App