Generation

generate functionSun, 13 Nov 2022

find longest increasing subsequence of an array of integers

int[] array = {5, 1, 0, 6, 4, 9, 12, 17, 22, 25}; int[] longest = new int[10]; int find(int[] array){ int len = 0; for(int i = 0; i < array.length; i++){ longest[i] = 1; for(int j = 0; j < i; j++){ if(array[i] > array[j] && longest[j] >= longest[i]) longest[i] = longest[j] + 1; } if(len < longest[i]) len = longest[i]; } return len; } find(array)

Want to kickstart your project?Use the new AI Studio to create your code