MCPcopy Create free account
hub / github.com/Rohit91singh9/Coding-DP-DSA / find

Class find

Find_Minimum_Character.java:37–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36import java.util.*;
37class find {
38 public static int findMinimumCharacters(String searchWord, String resultWord)
39 {
40 int p = 0;
41 int q = 0;
42 while(p < searchWord.length())
43 {
44 if(searchWord.charAt(p) == resultWord.charAt(q))
45 {
46 q += 1;
47 if(q == resultWord.length())
48 {
49 return 0;
50 }
51 } p += 1;
52 } return (resultWord.length() - q);
53 }
54 public static void main(String[] args) throws Exception
55 {
56 try (Scanner sc = new Scanner(System.in)) {
57 System.out.println("Enter Search Word");
58 String str1 = sc.nextLine();
59 System.out.println("Enter Result Word");
60 String str2 = sc.nextLine();
61 System.out.println(findMinimumCharacters(str1, str2));
62 }
63 }
64}
65
66/*
67 This is complete logic of a Program

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected