class Solution { // idea : create a new array say 'arr' which has sorted and unique elements from original array // find LCS between two arrays public int lengthOfLIS(int[] nums) { int n = nums.length; // store the original array into hashset to ignore the duplicates Set set = new HashSet<>(); for(int ele : nums) set.add(ele); // sort the elements in hashset by storing into array list List arr = new ArrayList<>(); arr.addAll(set); Collections.sort(arr); int m = arr.size(); // create a matrix int[][] t = new int[n+1][m+1]; // intialise the matrix with base condition for(int i=0; i