Game Night
InterviewTime limit2sMemory limit2048 MB
Given two equal-length passwords, count the positions where the letters differ, since only those magnets must be fetched from the box.
- Level
Easy2 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
Every Saturday, Geronimo organizes a game night for all his friends. One after another, his friends ask him for his Wi-Fi password. He has many friends and does not want to be interrupted every time he shares it, so he takes an old box of letter-shaped fridge magnets and spells the password out on the fridge.
Geronimo wants to change the Wi-Fi password after game night so that strangers who got it cannot use his network. He then has to update the password on the fridge too. The magnet box is a mess, so he does not want to spend much time searching it for the right letters, especially when the new password shares some letters with the old one.
Given the old and new Wi-Fi passwords, count how many letters he has to search for in the box to spell out the new password on the fridge.
Input
The first line contains one integer (), the length of the passwords. Both passwords have the same length.
The next two lines each contain one password of length . The passwords contain only lowercase letters, from a to z.
Output
Print one line with one integer, the number of letters that cannot be re-used between the two passwords.