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


Please Help Members By Posting Answers For Below Questions

Is html an oop?

761


write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory

2973


String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?

2136


What is coupling in oop?

767


What is polymorphism explain?

954


What is oops and why we use oops?

772


What is the advantage of oop over procedural language?

835


What is polymorphism in oop example?

715


write string class as your own class in java without using any built-in function

2193


What are the components of marker interface?

792


What are the 3 pillars of oop?

845


Can we create object of interface?

816


Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?

4461


What are the types of abstraction?

756


Can we create object of abstract class?

801