Problem description:

Solution:

time complexity: $O()$
space complexity: $O()$
reference:
related problem: