A linked list node is represented as a plain object `{ val, next }`. Implement `arrayToList(arr)` that converts an array into a linked list and returns the head node. Example: `arrayToList([1,2,3])` → `{ val:1, next:{ val:2, next:{ val:3, next:null } } }`.
+ 1 hidden test run on Submit.
Build nodes left to right, linking each to the next, and keep the head. O(n) time and space.
Run your code to see results.