How to find index of any Currency Symbols in a given string

Given a string txt, the task is to find the index of currency symbols present in the given string.


Input: txt = “Currency symbol of USA is $”;
Output: 26
Explanation :
The symbol $ is present at index 33.

Input: txt = “One US Dollar($) is equal to 75.70 Indian Rupee.”;
Output: 14

Naive Approach:
The simplest approach to solve the problem is to do the following: