@@ -0,0 +1,517 @@
+public class Solution%0A%7B%0A  public int candy (int%5B%5D ratings)%0A  %7B%0A    int cnt = 1;%0A    int lastUp = 1, lastDown = 1;%0A    for (int i = 1; i %3C ratings.length; ++i)%0A    %7B%0A      if (ratings%5Bi%5D %3E ratings%5Bi - 1%5D)%0A      %7B%0A        lastDown = 0;%0A        cnt += lastUp + 1;%0A        ++lastUp;%0A      %7D%0A      else if (ratings%5Bi%5D %3C ratings%5Bi - 1%5D)%0A      %7B%0A        lastUp = 1;%0A        cnt += lastDown + 1;%0A        ++lastDown;%0A      %7D%0A      else%0A      %7B%0A        ++cnt;%0A        lastUp = lastDown = 1;%0A      %7D%0A    %7D%0A    return cnt;%0A  %7D%0A%7D%0A

(Candy) [Wrong Answer] An wrong O(N) solution