fork download
  1. package Interview_Questions;
  2. import java.util.*;
  3. public class google_1 {
  4. static void main() {
  5. Scanner sc=new Scanner(System.in);
  6. int n=sc.nextInt();
  7. int[]arr=new int[n];
  8. for(int i=0;i<n;i++){
  9. arr[i]=sc.nextInt();
  10. }
  11. int k1=sc.nextInt();
  12. int k2=sc.nextInt();
  13. int ans=0;
  14. for(int i=2;i<n-2;i++){
  15. int cnt1=0;
  16. for(int j=i-1;j>=0;j--){
  17. if(arr[j]+arr[i]>k1){
  18. cnt1++;
  19. }
  20. }
  21. int k=i+1;
  22. int l=n-1;
  23. int cnt2=0;
  24. while(k<l){
  25. if(arr[k]+arr[l]>k2){
  26. cnt2+=l-k;
  27. l--;
  28. }
  29. else{
  30. k++;
  31. }
  32. }
  33. ans+=cnt1*cnt2;
  34. }
  35. System.out.println(ans);
  36. }
  37. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: class google_1 is public, should be declared in a file named google_1.java
public class google_1 {
       ^
1 error
stdout
Standard output is empty