diff --git a/Hashmaps:Longest consecutive Sequence b/Hashmaps:Longest consecutive Sequence index ab7b6b5..77cf03b 100644 --- a/Hashmaps:Longest consecutive Sequence +++ b/Hashmaps:Longest consecutive Sequence @@ -1,65 +1,37 @@ - - - +import java.util.Map; import java.util.HashMap; import java.util.ArrayList; +import java.util.Arrays; + public class Solution { public static ArrayList longestConsecutiveIncreasingSequence(int[] arr) { - HashMap map = new HashMap<>(); - ArrayList output = new ArrayList<>(); - - for(int i=0;i maxlength){ - maxlength = length; - start = starttemp; - }else if(length == maxlength){ - maxlength = length; - //start = 10 starttemp = 4 - for(int j=0;j map=new HashMap<>(); + ArrayList arrayList=new ArrayList<>(); + ArrayList arrayListcopy=new ArrayList<>(); + for(int i=0;iarrayList.size()){ + arrayList=arrayListcopy; + } + arrayListcopy=new ArrayList<>(); + } + ArrayList output=new ArrayList<>(); + output.add(arrayList.get(0)); + output.add(arrayList.get(arrayList.size()-1)); + + return output; + } +}