Interview 03: Coding Exercise Question: Write a program that is going to receive an array of unique integers in ascending order. You program must return a list of list of integers with the begin and the end of each sequence. Example 1: input: {1,3,4} output: {(1,1), (3,4)} Example 2: input: {1,2,3,5,6,8} output: {(1,3), (5,6), (8,8)}
Anonymous
public static void main(String[] args) { //int[] input = {1,3,4}; int[] input = { 1,2,3,5,6,8}; List result = new ArrayList(); int[] temp = new int[2]; temp[0] = input[0]; temp[1] = input[0]; result.add(temp); for(int i =1;i
Check out your Company Bowl for anonymous work chats.