56.Remove string 2 froM String 1

56

Problem of the Day:
Given two Strings s1 and s2, remove all the characters from s1 which is present in s2.



  • Input: s1=”expErIence”
    s2="E"
    output: s1=”exprIece”



  • Input: s1 = "Programming"
    s2 = "P"
    Output: rogramming


Comments


  1. class Main {
    public static void main(String[] args) {
    String s1="expErience";
    String s2="Enr";
    String result="";
    for(int i=0;i<s1.length();i++){
    char ch=s1.charAt(i);
    if(s2.indexOf(ch) == -1){
    result +=ch;
    }
    }
    System.out.print(result);
    }
    }

    ReplyDelete

Post a Comment

Popular posts from this blog

Strings

Arrays