Skip to content

Instantly share code, notes, and snippets.

@seanchen1991
Created December 17, 2019 16:58
Show Gist options
  • Save seanchen1991/d8c63f789dcfdf67e70552dd30fc24c8 to your computer and use it in GitHub Desktop.
Save seanchen1991/d8c63f789dcfdf67e70552dd30fc24c8 to your computer and use it in GitHub Desktop.
Smallest String Problem Statement

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment