J
javafreak
Guys
I have been thinking on this problem
Say I have a String input ="DSDFSDFSFSFDAAAAABBBBBBBBRRRRRRRR"
and i have a character array of the characters to be removed say {A,C}
So I need to delete the occurences of A and C in this string
One way is to traverse the String input for each character using
charAt() and for each character , run a for loop to check whether that
character exists in the "remove" Array
for eg:
1st char D,
Check whether it exists in A and C array
if both the string and remove array this soln O(n2) would be bad, can
somehow the soln be made more efficient of complexity n
Thanks
javafreak
I have been thinking on this problem
Say I have a String input ="DSDFSDFSFSFDAAAAABBBBBBBBRRRRRRRR"
and i have a character array of the characters to be removed say {A,C}
So I need to delete the occurences of A and C in this string
One way is to traverse the String input for each character using
charAt() and for each character , run a for loop to check whether that
character exists in the "remove" Array
for eg:
1st char D,
Check whether it exists in A and C array
if both the string and remove array this soln O(n2) would be bad, can
somehow the soln be made more efficient of complexity n
Thanks
javafreak