Given two strings S1 and S2. Delete from S2 all those charac

WBOY
发布: 2016-06-07 15:42:58
原创
1181 人浏览过

Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted. public class StringManipulation { public static void main(String args[]) { String s

 Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

 

 

 

 

 

public class StringManipulation {

 public static void main(String args[]) {

  String s1 = "ba";
  String s2 = "cbaaaabbcaaaa";
  
  
  for (int i = 0; i    for (int j = 0; j>=0 && s2.length()>0 &&j    
    while(s1.charAt(i) ==s2.charAt(j)){//处理连续状况
     s2 = s2.substring(0, j) + s2.substring(j + 1);
       j--;
       System.out.println(s2+s2.length()+"  "+j);
       if(j        if(s2.equals(""))break;
    }
   }
  }

  System.out.println(s2+"!!!");

 }

}

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板