Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int solution(int[] A){
- int whichTypeOfSubsequence = checkTypeOfSubsequence(0, A);
- int lengthOfSubsequence = 2;
- int numberOfSubseqences = 0;
- for(int i = 0; i < A.length-1; i++){
- if(whichTypeOfSubsequence == checkTypeOfSubsequence(i, A)){
- lengthOfSubsequence++;
- if(i == A.length -2){
- numberOfSubseqences += calculateNumberOfSubseqnuences(lengthOfSubsequence);
- }
- }
- else{
- numberOfSubseqences += calculateNumberOfSubseqnuences(lengthOfSubsequence);
- whichTypeOfSubsequence = checkTypeOfSubsequence(i, A);
- if(i == A.length -2){
- numberOfSubseqences += calculateNumberOfSubseqnuences(lengthOfSubsequence);
- }
- lengthOfSubsequence = 2;
- }
- }
- return numberOfSubseqences;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement