Last active
May 25, 2020 16:59
-
-
Save kevin49999/da68f26d73c230d188da4cddc7d99eac to your computer and use it in GitHub Desktop.
LeetCode Helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension String { | |
| subscript(_ index: Int) -> Character { | |
| return self[String.Index(utf16Offset: index, in: self)] | |
| } | |
| } | |
| extension String { | |
| func sub(_ l: Int, _ r: Int) -> String { | |
| let leftIndex = String.Index(utf16Offset: l, in: self) | |
| let rightIndex = String.Index(utf16Offset: r, in: self) | |
| return String(self[leftIndex...rightIndex]) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment