Skip to content

Instantly share code, notes, and snippets.

@CollinShoop
Created February 1, 2023 00:35
Show Gist options
  • Save CollinShoop/973ff9d5276008716293dd73b6b2b91a to your computer and use it in GitHub Desktop.
Save CollinShoop/973ff9d5276008716293dd73b6b2b91a to your computer and use it in GitHub Desktop.
type OrderedStream struct {
index int
values []string
}
func Constructor(n int) OrderedStream {
return OrderedStream {
index: 0,
values: make([]string, n),
}
}
func (this *OrderedStream) Insert(idKey int, value string) []string {
this.values[idKey-1] = value
ret := []string{}
for this.index < len(this.values) && this.values[this.index] != "" {
ret = append(ret, this.values[this.index])
this.index++
}
return ret
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment