GiventwostringsS1andS2.DeletefromS2allthosecharac
來源:懂視網
責編:小采
時間:2020-11-09 15:29:41
GiventwostringsS1andS2.DeletefromS2allthosecharac
GiventwostringsS1andS2.DeletefromS2allthosecharac: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
導讀GiventwostringsS1andS2.DeletefromS2allthosecharac: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 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 < s1.length(); i++) {
for (int j = 0; j>=0 && s2.length()>0 &&j < s2.length(); 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<0){j=0;}
if(s2.equals(""))break;
}
}
}
System.out.println(s2+"!!!");
}
}
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
GiventwostringsS1andS2.DeletefromS2allthosecharac
GiventwostringsS1andS2.DeletefromS2allthosecharac: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