Runtime Error with last executed input: {}

  • 0

    My Java code got the Runtime Error, with last executed input {}. Thinking it's null input, but I suppose I have handled that well, haven't I? Plz help, thanks!

    public ListNode deleteDuplicates(ListNode head) {
        ListNode curr = head;
        ListNode prev = null;
        boolean[] arr = new boolean[Integer.MAX_VALUE];
        while (curr != null) {
          if (arr[head.val]) {
          } else {
            arr[head.val] = true;
            prev = curr;
          curr =;
        return head;

  • 1

    You get runtime error probably due to allocating too much memory:

    boolean[] arr = new boolean[Integer.MAX_VALUE];

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.