Skip to content

Instantly share code, notes, and snippets.

@seanchen1991
Created December 17, 2019 16:58
Show Gist options
  • Select an option

  • Save seanchen1991/d8c63f789dcfdf67e70552dd30fc24c8 to your computer and use it in GitHub Desktop.

Select an option

Save seanchen1991/d8c63f789dcfdf67e70552dd30fc24c8 to your computer and use it in GitHub Desktop.

Revisions

  1. seanchen1991 created this gist Dec 17, 2019.
    22 changes: 22 additions & 0 deletions smallest_string.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # Smallest String

    Write a function that takes two strings and returns the "smallest" string. If
    both strings are equal, you may return either string. Strings will only consist
    of lowercase letters and numbers: [a - z][0 - 9]. Letters earlier in the alphabet
    are considered smaller. Consecutive digits in the string should be considered a single
    number.

    ```
    Examples:
    input: "a", "b"
    expected output: "a" since "a" comes before "b" alphabetically
    input: "a1", "a2"
    expected output: "a1" since 1 comes before 2
    input: "a10", "a2"
    expected output: "a2" since 2 comes before 10
    ```

    Analyze the time and space complexity of your solution.