import java.util.*;
/*
* public class ListNode {
* int val;
* ListNode next = null;
* public ListNode(int val) {
* this.val = val;
* }
* }
*/
public class Solution {
public ArrayList<Integer> listnodeToVector (ListNode head) {
ArrayList<Integer> list = new ArrayList<>();
if(head==null)return list;
while(head!=null){
list.add(head.val);
head = head.next;
}
return list;
}
}

京公网安备 11010502036488号