File tree Expand file tree Collapse file tree 2 files changed +17
-12
lines changed 
s3345_smallest_divisible_digit_product_i 
s3346_maximum_frequency_of_an_element_after_performing_operations_i Expand file tree Collapse file tree 2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change 11package  g3301_3400 .s3345_smallest_divisible_digit_product_i ;
22
3- // #Easy #2024_11_12_Time_1_ms_(59.15%)_Space_40.5_MB_(98.74 %) 
3+ // #Easy #Math #Enumeration #2024_11_13_Time_0_ms_(100.00%)_Space_41.2_MB_(29.77 %) 
44
55public  class  Solution  {
66    public  int  smallestNumber (int  n , int  t ) {
7-         for  (int  i  = n ; i  < 101 ; i ++) {
8-             if  (digProduct (i ) % t  == 0 ) {
9-                 return  i ;
7+         int  num  = -1 ;
8+         int  check  = n ;
9+         while  (num  == -1 ) {
10+             int  product  = findProduct (check );
11+             if  (product  % t  == 0 ) {
12+                 num  = check ;
1013            }
14+             check  += 1 ;
1115        }
12-         return  - 1 ;
16+         return  num ;
1317    }
1418
15-     private  int  digProduct (int  n ) {
16-         int  pro  = 1 ;
17-         while  (n  > 0 ) {
18-             pro  *= n  % 10 ;
19-             n  /=  10 ;
19+     private  int  findProduct (int  check ) {
20+         int  res  = 1 ;
21+         while  (check  > 0 ) {
22+             res  *= check  % 10 ;
23+             check  =  check  /  10 ;
2024        }
21-         return  pro ;
25+         return  res ;
2226    }
2327}
Original file line number Diff line number Diff line change 11package  g3301_3400 .s3346_maximum_frequency_of_an_element_after_performing_operations_i ;
22
3- // #Medium #2024_11_12_Time_7_ms_(96.72%)_Space_57.4_MB_(44.86%) 
3+ // #Medium #Array #Sorting #Binary_Search #Prefix_Sum #Sliding_Window 
4+ // #2024_11_13_Time_7_ms_(96.84%)_Space_56.4_MB_(92.35%) 
45
56public  class  Solution  {
67    private  int  getMax (int [] nums ) {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments