0

Given two strings, find the number of common characters between them. Example: For s1 = "aabcc" and s2 = "adcaa", the output should be commonCharacterCount(s1, s2) = 3. Strings have 3 common characters - 2 "a"s and 1 "c".

It's pretty simple in C or Python, but is it possibly to write it in MIPS?

Erik Eidt
  • 23,049
  • 2
  • 29
  • 53
  • 1
    Nope, cannot be done in MIPS -- just kidding. MIPS, like C and Python, is [Turing Complete](https://en.wikipedia.org/wiki/Turing_completeness), which is just a fancy way of saying they can compute anything so are all equally powerful. – Erik Eidt Jun 05 '22 at 17:48
  • How would you do it in C? Take your C approach and translate it to assembly, that's easier than writing it in assembly from scratch, when you don't know assembly. – Erik Eidt Jun 05 '22 at 17:50
  • Same question for x86 assembly: [How do I display the number of equal and different characters between two strings in assembly?](https://stackoverflow.com/q/71674283) - an answer there describes an algorithm that's slow but simple to implement in asm, destroying one of the input strings. (As well as showing code for it: x86 `rep scasb` is just a byte search which you could do with a MIPS loop.) – Peter Cordes Jun 06 '22 at 01:05

0 Answers0