import java.util.ArrayList; import java.util.List; public class LIS { public static int lowerBound(List a, int low, int high, int element){ while(low < high){ int middle = low + (high - low)/2; if(element > a.get(middle)) low = middle + 1; else high = middle; } return low; } public static int upperBound(List a, int low, int high, int element){ while(low < high){ int middle = low + (high - low)/2; if(a.get(middle) > element) high = middle; else low = middle + 1; } return low; } public static int longestIncreasingSubsequence(List a){ //equals included then upperbound // else lower bound use as required ArrayList ans = new ArrayList<>(); for(int i=0;ians.size()){ ans.add(a.get(i)); } else ans.set(x,a.get(i)); } return ans.size(); } }