class Solution {
    int max = 0;
    public int maximumRequests(int n, int[][] requests) {
        helper(requests, 0, new int[n], 0);
        return max;
    }
    
    private void helper(int[][] requests, int index, int[] count, int num) {
        // Traverse all n buildings to see if they are all 0. (means balanced)
        if (index == requests.length) {
            for (int i : count) {
                if (0 != i) {
                    return;
                }
            }
            max = Math.max(max, num);
            return;
        }
		// Choose this request
        count[requests[index][0]]++;
        count[requests[index][1]]--;
        helper(requests, index + 1, count, num + 1);
        count[requests[index][0]]--;
        count[requests[index][1]]++;
        
		// Not Choose the request
        helper(requests, index + 1, count, num);
    }
}
@@ -1,8 +1,83 @@
+package com.fishercoder.solutions;%0A%0Apublic class _1601 %7B%0A    public static 
 class So
@@ -82,19 +82,24 @@
 Solution
+1
  %7B%0A
+    
     int 
@@ -107,16 +107,21 @@
 ax = 0;%0A
+%0A    
     publ
@@ -170,32 +170,36 @@
 ests) %7B%0A        
+ 
+   
 helper(requests,
@@ -222,24 +222,28 @@
 0);%0A        
+    
 return max;%0A
@@ -250,15 +250,19 @@
     
-%7D
+    %7D%0A
 %0A    
-%0A
     
@@ -342,16 +342,20 @@
         
+    
 // Trave
@@ -421,24 +421,28 @@
 ed)%0A        
+  
+  
 if (index ==
@@ -457,24 +457,28 @@
 s.length) %7B%0A
+    
             
@@ -511,24 +511,28 @@
             
+    
 if (0 != i) 
@@ -549,32 +549,36 @@
             
+    
 return;%0A
             
@@ -557,32 +557,36 @@
         return;%0A
+    
                 
@@ -591,34 +591,42 @@
   %7D%0A            
-%7D%0A
+    %7D%0A    
             max 
@@ -655,32 +655,36 @@
             
+    
 return;%0A
         %7D%0A%09%09
@@ -663,32 +663,36 @@
         return;%0A
+    
         %7D%0A%09%09// C
@@ -685,18 +685,28 @@
       %7D%0A
-%09%09
+            
 // Choos
@@ -712,32 +712,36 @@
 se this request%0A
+    
         count%5Bre
@@ -761,32 +761,36 @@
 %5B0%5D%5D++;%0A        
+  
+  
 count%5Brequests%5Bi
@@ -798,24 +798,28 @@
 dex%5D%5B1%5D%5D--;%0A
+    
         help
@@ -859,32 +859,36 @@
 m + 1);%0A        
+    
 count%5Brequests%5Bi
@@ -900,32 +900,36 @@
 %5B0%5D%5D--;%0A        
+  
+  
 count%5Brequests%5Bi
@@ -941,24 +941,25 @@
 %5B1%5D%5D++;%0A
+%0A
         
 %0A%09%09// No
@@ -954,11 +954,12 @@
     
-%0A%09%09
+    
 // N
@@ -980,32 +980,36 @@
 request%0A        
+  
+  
 helper(requests,
@@ -1029,19 +1029,29 @@
 ount, num);%0A
+        %7D%0A
     %7D%0A%7D

refactor 1601