v1 time O(n) space O(1) Accepted

make good use of dummy head