摘要:        
经过网上搜索,写出了个时间复杂度O(n),空间也O(n)的算法。据说空间可以优化到O(1),这个再表。做法是先从左向右扫一遍,然后再从右向左扫一遍。public class Solution { public int candy(int[] ratings) { int len = ratings.length; if (len == 0) return 0; int num[] = new int[len]; int cnt = 0; for (int i = 1; i ratings[i - 1]) { ...    阅读全文
posted @ 2013-10-09 15:27
阿牧遥
阅读(352)
评论(0)
推荐(0)
        
 
                     
                    
                 
                    
                
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号