Skip to content

Instantly share code, notes, and snippets.

@vrat28
Created April 13, 2021 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrat28/5de5584788dbd8678d73b858bc417d25 to your computer and use it in GitHub Desktop.
Save vrat28/5de5584788dbd8678d73b858bc417d25 to your computer and use it in GitHub Desktop.
Flatten a nested list with recursion
func flattenList(_ nestedList: [NestedInteger]) {
for element in nestedList {
if element.isInteger() {
list.append(element.getInteger())
}
else{
flattenList(element.getList())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment