Find the position of difference between two strings

前端 未结 6 1600
别那么骄傲
别那么骄傲 2021-01-04 00:08

I have two strings of equal length, how can I find all the locations where the strings are different?

For example, \"HELPMEPLZ\" and \"HELPNEPLX\" are different at p

6条回答
  •  轮回少年
    2021-01-04 00:27

    Easiest way is to split data into two char arrays and then loop through comparing the letters and return the index when the two chars do not equal each other.

    This method will work fine as long as both strings are equal in length.

提交回复
热议问题