Meta interview question

Two medium-difficulty algorithms, the interviewer was very kind.