def re_adjust(self, ratings, dp, ind):
        # backward adjust
        original = dp[ind]
        if original==1: return  # no adjustment needed
        i = ind
        candy = 1
        while i>0 and ratings[i-1]>ratings[i]:  # test case [8, 7, 6, 5, 4, 3, 2, 1]
            dp[i] = candy
            candy += 1
            i -= 1
        # peak
        if original<1:  # test case [4, 2, 3, 4, 1]
            dp[i] = candy
dataset/ETHPy150Open algorhythms/LeetCode/135 Candy.py/Solution.re_adjust/original