| 35 | |
| 36 | import java.util.*; |
| 37 | class 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 |
nothing calls this directly
no outgoing calls
no test coverage detected