import { ListNode } from "./LinkList" ; param { ListNode } pHead param { ListNode } qHead return { ListNode } function listSum ( pHead , qHead ) { let n = new ListNode ( 0 , null ) ; let head = n ; let plus = 0 ; while ( pHead || qHead || plus ) { let val1 = 0 , val2 = 0 ; if ( pHead ) { val1 = pHead . val ; pHead = pHead . next ; } if ( qHead ) { val2 = qHead . val ; qHead = qHead . next ; } let sum = val1 + val2 + plus ; n . next = new ListNode ( sum % 10 , null ) ; plus = Math . floor ( sum / 10 ) ; n = n . next ; } return head . next ; } export { listSum } ;