ZTE Interview Question

One problem from the leetcode.