My instructor has asked me to analyze my algorithm. The assignment was to write a program that takes in a list of numbers as user input, and finds the longest sequence of like-numbers, marks the number, and marks the starting index. That part is done, but if anyone has any comments on my code, those are welcome too. Below are his instructions:

Analysis of algorithms is the determination of the amount of time and space resources required to execute it. Usually, the efficiency or running time of an algorithm is stated as a function relating the input length to the number of steps, known as time complexity, or volume of memory, known as space complexity.
However, the main concern of analysis of algorithms is the required time or performance. Generally, we perform the following types of analysis −

• Worst-case − The maximum number of steps taken on any instance of size n.

• Best-case − The minimum number of steps taken on any instance of size n.

• Average case − An average number of steps taken on any instance of size n.

TLDR; Would my algorithm be O(n) because the program has to iterate through the entire list once? Also does my while loop affect algorithm efficiency?

```
import java.util.ArrayList;
import java.util.Scanner;

public class Practice {

    public static void main(String[] args) {

        Scanner keyboard = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<Integer>();
        String temporaryNumber;

        System.out.println("Enter a list of integers, when done, enter 0:");
        while(true) {
            try {
                int j = 0;
                temporaryNumber = keyboard.next();
                int permNumber = Integer.parseInt(temporaryNumber);
                list.add(permNumber);
                j++;
                System.out.println(list); // Displays list as it's typed, OPTIONAL
                if (permNumber == 0) {
                    break;
                }
                else if (permNumber < 0) {
                    System.out.println("Input must be a positive integer.");
                    list.remove(j);
                }
            }
            catch (NumberFormatException e) {
                System.out.println("Input must be a positive integer.");
            }
        }
        keyboard.close();
                int sequenceCount = 1;
                int highestSequenceCount = 0;
                int longestSeqInteger = 0;
                int startingIndexCount = 0;

        for (int i = 1; i < list.size() -1; i++) {
                if (list.get(i) == list.get(i-1)) {
                    sequenceCount++;
                }
                else {

                    if (highestSequenceCount < sequenceCount) {
                        highestSequenceCount = sequenceCount;
                        longestSeqInteger = list.get(i-1);
                        startingIndexCount = i - highestSequenceCount;
                        sequenceCount = 1;
                    }
                    else {
                        sequenceCount = 1;
                }
            }
        }
        System.out.println("The longest same number sequence starts at index " + startingIndexCount + ", with " + 
        highestSequenceCount + " values of " + longestSeqInteger); //temp
    }
}

```