Skip to content

Instantly share code, notes, and snippets.

@PascalUlor
Forked from seanchen1991/smallest_string.md
Created December 17, 2019 18:13
Show Gist options
  • Save PascalUlor/1b3bf4e2182e8396b6f44801ac0bcdb4 to your computer and use it in GitHub Desktop.
Save PascalUlor/1b3bf4e2182e8396b6f44801ac0bcdb4 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