fork download
  1. class Solution {
  2. public long countSubarrays(int[] nums, int minK, int maxK) {
  3. int n= nums.length;
  4.  
  5. long count=0;
  6.  
  7. for(int i=0;i<n;i++){
  8. for(int j=i;j<n;j++){
  9. if(nums[j]< minK || nums[j] > maxK){
  10. break;
  11. }
  12. count++;
  13. }
  14. }
  15.  
  16. // for(int i=0;i<n;i++){
  17. // for(int j=i;j<n;j++){
  18. // int k=i;
  19.  
  20. // int flag=0;
  21. // while(k<=j){
  22. // if(nums[k]< minK || nums[k] > maxK){
  23. // flag=1;
  24. // }
  25. // k++;
  26. // }
  27. // if(flag==0){
  28. // count++;
  29. // }
  30. // }
  31. // }
  32.  
  33. return count;
  34. }
  35. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
spoj: The program compiled successfully, but main class was not found.
      Main class should contain method: public static void main (String[] args).
stdout
Standard output is empty