DEV Community

Discussion on: Common Character Count!!Swift Coding Challenge!!

Collapse
 
gualtierofr profile image
Gualtiero Frigerio

If I was given this question during an interview I'd have asked for clarification, as to me there are 2 common characters between the two strings: a and c. Why do I need to count a 2 times?
Under your assumption, the code you posted is correct and I think it is the easiest.
Only a little detail: characters is deprecated and you can iterate through the string by writing
for char in string {
...
}

Collapse
 
thetealpickle profile image
✨ thetealpickle πŸ“±

Thanks for the tip about characters πŸ‘, I didn't realize it was deprecated. Back to for loops 😁