Given two strings like x=?hello? and y=?open?, remove any
character from string x which is also used in string y,
thus making the result x=?hll?.
Answer Posted / vijay bhatia
string processString(string x, string y) {
string res = "";
int occuranceCount[26];
for(int i=0; i<26; i++) {
occuranceCount[i] = 0;
}
for(i=0; i<y.size(); i++) {
occuranceCount[y[i]-'a']++;
}
for(i=0; i<x.size(); i++) {
if (occuranceCount[x[i]-'a'] == 0) {
res += x[i];
}
}
return res;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is encapsulation and abstraction? How are they implemented in C++?
What is the diamond problem in inheritance?
Why do we use oop?
Can we override main method?
What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?
What is methods in oop?
What is overriding vs overloading?
What are oops functions?
What is a superclass in oop?
What does and I oop and sksksk mean?
How do you explain polymorphism?
Is enum a class?
Why is there no multiple inheritance?
What is abstraction in oops with example?
Can enum be null?