August 13, 2024 |4.0K Views

    Replace a character c1 with c2 and c2 with c1 in a string S

      Share   Like
    Description
    Discussion

    Given a string S, c1 and c2. Replace character c1 with c2 and c2 with c1. Examples: Input : grrksfoegrrks, c1 = e, c2 = r Output : geeksforgeeks Input : ratul, c1 = t, c2 = h Output : rahul Replace a character c1 with c2 and c2 with c1 in a string S : https://www.geeksforgeeks.org/replace-character-c1-c2-c2-c1-string-s/given a string S, c1 and c2. Replace character c1 with c2 and c2 with c1. 
    Examples: 
     

    Input : grrksfoegrrks,
           c1 = e, c2 = r 
    Output : geeksforgeeks

    Input : ratul,
           c1 = t, c2 = h 
    Output : rahul


    Replace a character c1 with c2 and c2 with c1 in a string S  : https://www.geeksforgeeks.org/replace-character-c1-c2-c2-c1-string-s/