fork download
  1. class Solution {
  2. public int maxBalancedSubarray(int[] nums) {
  3. int xor[]=new int[nums.length], ps[]=new int[nums.length];
  4. HashMap<String,Integer> map=new HashMap<>();
  5. map.put("0#0",-1);
  6. int sum=0, cnt=0, mlen=0;
  7. for(int i=0;i<nums.length;i++){
  8. sum^=nums[i];
  9. xor[i]=sum;
  10. if(nums[i]%2==0){
  11. cnt+=1;
  12. }else{
  13. cnt-=1;
  14. }
  15. int bit=0;
  16. String k=cnt+"#"+sum;
  17. if(map.containsKey(k)){
  18. int j=map.get(k);
  19. mlen=Math.max(mlen,i-j);
  20. }else{
  21. map.put(k,i);
  22. }
  23. ps[i]=cnt;
  24. }
  25. return mlen;
  26. }
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:4: error: cannot find symbol
        HashMap<String,Integer> map=new HashMap<>();
        ^
  symbol:   class HashMap
  location: class Solution
Main.java:4: error: cannot find symbol
        HashMap<String,Integer> map=new HashMap<>();
                                        ^
  symbol:   class HashMap
  location: class Solution
2 errors
stdout
Standard output is empty