Skip to content

Instantly share code, notes, and snippets.

@aaronshaver
Created April 6, 2022 23:11
Show Gist options
  • Save aaronshaver/9f810ec8a91db8a203e7a3b5ce3a8304 to your computer and use it in GitHub Desktop.
Save aaronshaver/9f810ec8a91db8a203e7a3b5ce3a8304 to your computer and use it in GitHub Desktop.
RegEx finding two different groups, e.g. "13" gets (1,3) and "13#" gets (13#)
# https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping/
def freqAlphabets(self, s):
return ''.join(chr(int(i[:2]) + 96) for i in re.findall(r'\d\d#|\d', s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment