eveningwater/to-offer

首尾交换

Closed this issue · 1 comments

function reverseArray(head) {
             let result = [];
             while (head != null){
                 result.push(head.Val)
                 head = head.Next
             }
            
             for(let i = 0; i< result.length/2;i++){
                 let temp = result[i];
                 result[i] = result[result.length -1 - i];
                 result[result.length-1-i] = temp
             }
             console.log(result);
             return result
       }

提交pull requests