Complex Java Interview Coding