| Algorithm | 
                        
                        
                          
                            - Assume optimal partitioning for the first i values with at most
  bins is   
                            | 
                        
                        
                          
                            - Consider placement of the last bin
 
                            | 
                        
                        
                          
                            - Choice is any of the i gaps
 
                            | 
                        
                        
                          
                            - For each such placement at gap 
  , at most   bins have been placed optimally for the first   values 
                            | 
                        
                        
                          
                            - This leads to the recursion
 
                            | 
                        
                        
                           | 
                        
                        
                          
                            - Dynamic programming (DP) solution
 
                            | 
                        
                        
                          
                            - Table of size 
  
                            | 
                        
                        
                          
                            - Start with cell 
 and proceed in a column-scan order 
                            | 
                        
                        
                          
                            - Computation for cell
  requires values at cells   
                            | 
                        
                        
                          
                            - Running time: 
  
                            |