← Back to challenges

Find the Shared Letters between Two Strings

PythonHardstringsconditionsalgorithms

Instructions

Given two strings, return a string containing only the letters shared between the two.

Examples

shared_letters("house", "home") ➞ "eho"

shared_letters("Micky", "mouse") ➞ "m"

shared_letters("house", "villa") ➞ ""

Notes

  • If none of the letters are shared, return an empty string.
  • The function should be case insensitive (e.g. comparing A and a should return a).
  • Sort the resulting string alphabetically before returning it.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Simple Circle Collision Detection