Find first and last index of target | ByteDance Interview Question