string word1 = "misisipi";
string word2 = "mississippi";
I would like to ‘compare’ these strings some how and be able to ‘toss out’ letters that are not common.
For example word2 would be cut down to "misisipi", making sure to keep the ‘S’es in order, and word1 would not change since all of its characters are in word2. I recognize how to remove an element in a string, but this time I want to maintain the order. For example, if I did not maintain the order, after comparison word2 would be "missipi", which is not what I want.
Try copying the valid
word2characters intoword1as you iterate through each element ofword1.May want to allocate
tempbeforehand, if you want speed.