/*
* function ListNode(val, next) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
*/
function reverse(l){
let v = ''
while(l){
v += l.val;
l = l.next
}
return v.split('').reduce((p,c)=>{
c = new ListNode(+c)
c.next = p
return c
},null)
}