Minimum indexed character
Submissions: 2710   Accuracy:

50.87%

  Difficulty: Easy   Marks: 2

Given a string str and another string patt. Find the character in patt that is present at the minimum index in str. If no character of patt is present in str then print ‘No character present’.

Input Format:
The first line of input contains an integer T denoting the number of test cases. Then the description of T test cases follow. Each test case contains two strings str and patt respectively.

Output Format:
Print the character in patt that is present at the minimum index in str.
Print "No character present" (without quotes) if no character of patt is present in str.

Your Task:
This is a function problem. You only need to complete the function printMinIndexCharN that prints the answer. The newline is automatically appended by the driver code.

Constraints:
1 <= T <= 105
1 <= |str|,|patt| <= 105

Example:
Input:

2
geeksforgeeks
set
adcffaet
onkl

Output:
e
No character present

Explanation:
Testcase 1:
e is the character which is present in given patt "geeksforgeeks" and is first found in str "set".

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ayush Govil
Author: Ayush Govil 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.