B. Error Correct System (CF Round #296 (Div. 2))

Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing stringsSandTof equal length to be "similar". After a brief search on the Internet, he learned about theHamming distancebetween two stringsSandTof the same length, which is defined as the number of positions in whichSandThave different characters. For example, the Hamming distance between words "permanent" and "pergament" is two, as these words differ in the fourth and sixth letters.

Moreover, as he was searching for information, he also noticed that modern search engines have powerful mechanisms to correct errors in the request to improve the quality of search. Ford doesn’t know much about human beings, so he assumed that the most common mistake in a request is swapping two arbitrary letters of the string (not necessarily adjacent). Now he wants to write a function that determines which two letters should be swapped in stringS, so that the Hamming distance between a new stringSand stringTwould be as small as possible, or otherwise, determine that such a replacement cannot reduce the distance between the strings.

Help him do this!

,他们不计后果的彼此拥抱,握紧双手,怕天会亮,怕爱会走。

B. Error Correct System (CF Round #296 (Div. 2))

相关文章:

你感兴趣的文章:

标签云: