fork download
  1. /**
  2.  * Definition for singly-linked list.
  3.  * public class ListNode {
  4.  * int val;
  5.  * ListNode next;
  6.  * ListNode() {}
  7.  * ListNode(int val) { this.val = val; }
  8.  * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
  9.  * }
  10.  */
  11. class Solution {
  12. public ListNode reverseList(ListNode head) {
  13.  
  14.  
  15. ListNode cur = head;
  16. ListNode prev = null;
  17. ListNode next = null;
  18.  
  19. while (cur != null) {
  20.  
  21. next = cur.next;
  22. cur.next = prev;
  23. prev = cur;
  24. cur = next;
  25. }
  26.  
  27. return prev;
  28. }
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:12: error: cannot find symbol
    public ListNode reverseList(ListNode head) {
                                ^
  symbol:   class ListNode
  location: class Solution
Main.java:12: error: cannot find symbol
    public ListNode reverseList(ListNode head) {
           ^
  symbol:   class ListNode
  location: class Solution
Main.java:15: error: cannot find symbol
        ListNode cur = head;
        ^
  symbol:   class ListNode
  location: class Solution
Main.java:16: error: cannot find symbol
        ListNode prev = null;
        ^
  symbol:   class ListNode
  location: class Solution
Main.java:17: error: cannot find symbol
        ListNode next = null;
        ^
  symbol:   class ListNode
  location: class Solution
5 errors
stdout
Standard output is empty