Quote
Given two character arrays a[] and b[], remove from b[] all occurrences of all characters that occur in array a[]. You need to do this in-place i.e. without using an extra array of characters. E.g.:
Input: a[] = [‘G’, ‘O’]
Input b[] = [‘G’, ’O’, ’O’, ’G’, ’L’, ’E’]
Output: b[] = [‘L’, ‘E’]
Input: a[] = [‘G’, ‘O’]
Input b[] = [‘G’, ’O’, ’O’, ’G’, ’L’, ’E’]
Output: b[] = [‘L’, ‘E’]
Code :
public class ReplaceCharacterArray{
public static void main(String args[]){
char a[] = [‘G’, ‘O’]
char b[] = [‘G’, ’O’, ’O’, ’G’, ’L’, ’E’]
//to replace all the occurences of all the characters of
//a[] array in b[] array we have below logic.
for(int i=0;i<a.length;i++){
for(int j=0;j<b.length;j++){
if(b[j] == a[i]){
//im stuck here how do i proceed with code from here.whats wrong ?
}
}

New Topic/Question
Reply




MultiQuote







|