ByteDance Interview Question

A easy-hard level coding question