My approach on paper (take it as an hint) - picture (O(n)

facebook
Tags: #<Tag:0x00007f2422be2038>

#1