fork download
  1. class Solution {
  2. public String[] assignUmbrella(int[] rain) {
  3. int n=rain.length;
  4. String[] res = new String[n];
  5.  
  6. int count_a=0;
  7. int count_b=0;
  8.  
  9. for(int i=0;i<n;i++){
  10. if(i<=n-2 && rain[i]==1 && rain[i+1]==1 && count_a <= count_b){
  11. //now alice gets the chance
  12. count_a++;
  13. res[i]="Alice";
  14. }
  15. else if(i<=n-2 && rain[i]==1 && rain[i+1]==0){
  16. //now bob gets the chance
  17. count_b++;
  18. res[i]="Bob";
  19. }
  20. else if(i<=n-2 && rain[i]==1 && rain[i+1]==1 && count_a > count_b){
  21. //now bob gets the chance
  22. count_b++;
  23. res[i]="Bob";
  24. }
  25. else if(rain[i]==0){
  26. res[i]="None";
  27. }
  28. else if(i==n-1 && rain[i]==1){
  29. res[i]="Bob";
  30. }
  31. }
  32.  
  33. return res;
  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