File tree Expand file tree Collapse file tree 1 file changed +0
-5
lines changed 
src/main/java/g3301_3400/s3395_subsequences_with_a_unique_middle_mode_i Expand file tree Collapse file tree 1 file changed +0
-5
lines changed Original file line number Diff line number Diff line change 88import  java .util .Map ;
99
1010public  class  Solution  {
11- 
1211    private  static  final  int  MOD  = 1000000007 ;
1312
1413    public  int  subsequencesWithMiddleMode (int [] a ) {
1514        int  n  = a .length ;
16- 
1715        // Create a dictionary to store indices of each number 
1816        Map <Integer , List <Integer >> dict  = new  HashMap <>();
1917        for  (int  i  = 0 ; i  < n ; i ++) {
2018            dict .computeIfAbsent (a [i ], k  -> new  ArrayList <>()).add (i );
2119        }
22- 
2320        long  ans  = 0L ;
24- 
2521        // Iterate over each unique number and its indices 
2622        for  (Map .Entry <Integer , List <Integer >> entry  : dict .entrySet ()) {
2723            List <Integer > b  = entry .getValue ();
2824            int  m  = b .size ();
29- 
3025            for  (int  k  = 0 ; k  < m ; k ++) {
3126                int  i  = b .get (k );
3227                int  r  = m  - 1  - k ;
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments