Advertisement
Coriic

Untitled

Apr 27th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. public int solution(int[] A){
  2. int whichTypeOfSubsequence = checkTypeOfSubsequence(0, A);
  3. int lengthOfSubsequence = 2;
  4. int numberOfSubseqences = 0;
  5. for(int i = 0; i < A.length-1; i++){
  6. if(whichTypeOfSubsequence == checkTypeOfSubsequence(i, A)){
  7. lengthOfSubsequence++;
  8. if(i == A.length -2){
  9. numberOfSubseqences += calculateNumberOfSubseqnuences(lengthOfSubsequence);
  10. }
  11. }
  12. else{
  13. numberOfSubseqences += calculateNumberOfSubseqnuences(lengthOfSubsequence);
  14. whichTypeOfSubsequence = checkTypeOfSubsequence(i, A);
  15. if(i == A.length -2){
  16. numberOfSubseqences += calculateNumberOfSubseqnuences(lengthOfSubsequence);
  17. }
  18. lengthOfSubsequence = 2;
  19. }
  20. }
  21. return numberOfSubseqences;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement