Facebook coding interview
I am %100 sure that this is the correct answer,


I'm not so sure... I dumped your code into an online compiler*. I made very minor adjustments, moving target to a parameter and adding semicolons which aren't a big deal since you probably didn't have a compiler when writing it. I did not modify your code beyond that and treated it like a black-box.

import java.util.Arrays;

class Main {
  static boolean test(int[] arr, int target) {

    int start = 0;
    int end = 0;

    int total = 0;

    while (end &lt; arr.length) {

      total += arr[end]; // 1 3 1 4 = 9

      while (total &gt;= target) {

        total -= arr[start]; // 8

        start++;

        if (total == target) {
          return true;
        }

      }
      end++;
    }

    return false;
  }

  static class Input {
    int[] sequence;
    int target;

    Input(int[] sequence, int target) {
      this.sequence = sequence;
      this.target = target;
    }
  }

  public static void main(String[] args) {
    Input[] inputs = new Input[] { 
      new Input(new int[]{1, 3, 1, 4, 23}, 8),
      new Input(new int[]{1, 3, 1, 4, 23}, 7),
      new Input(new int[] {}, 0), 
      new Input(new int[] {}, 1),
      new Input(new int[] { 0 }, 0), 
      new Input(new int[] { 0 }, 1),  
      new Input(new int[] { 1 }, 1), 
      new Input(new int[] { -1 }, -1), 
      new Input(new int[] { Integer.MAX_VALUE }, Integer.MAX_VALUE),
      new Input(new int[] { 1, Integer.MAX_VALUE }, Integer.MAX_VALUE),
      new Input(new int[] { Integer.MIN_VALUE }, Integer.MIN_VALUE),
      new Input(new int[] { 1, 1, 1 }, 2),
      new Input(new int[] { 1, 1 }, 2),
      new Input(new int[] { 1, 0, 1 }, 2),
    };

    for (Input input : inputs) {
      System.out.print(String.format("%s, %d =&gt; ", Arrays.toString(input.sequence), input.target));
      try {

      System.out.println(
          test(input.sequence, input.target));
      } catch (Exception e) {
        System.out.println("Caught exception: " + e.getMessage() );
      }
    }
  }
}


That produced this output:

OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
[1, 3, 1, 4, 23], 8 =&gt; true
[1, 3, 1, 4, 23], 7 =&gt; false
[], 0 =&gt; false
[], 1 =&gt; false
[0], 0 =&gt; true
[0], 1 =&gt; false
[1], 1 =&gt; false
[-1], -1 =&gt; Caught exception: Index 1 out of bounds for length 1
[2147483647], 2147483647 =&gt; false
[1, 2147483647], 2147483647 =&gt; false
[-2147483648], -2147483648 =&gt; Caught exception: Index 1 out of bounds for length 1
[1, 1, 1], 2 =&gt; false
[1, 1], 2 =&gt; false
[1, 0, 1], 2 =&gt; false



Your code was initially not wrapped into a method. Try to make it look like production quality code. That's ostensibly what the interview is looking at and writing all day.
Since it wasn't in a method, it implies you didn't consider writing tests.
Writing tests made it trivial to reveal cases that threw exceptions.
You didn't specify what should happen with an empty list which implies you didn't ask about that. 
^^^ same with overflows. "Inputs that may cause overflows will cause undefined behavior" is a perfectly acceptable precondition in an interview IF you acknowledge that you have recognized this possibility, have a  notion of how to handle it, and the interviewer allows it.
It's also possible to yield incorrect answers with fairly trivial inputs, e.g. [1, 1]


*I do not recommend this online IDE, it felt very buggy. If someone has a better alternative I would be grateful.