ByteDance Interview Question

It was an LC med/hard