> For the complete documentation index, see [llms.txt](https://851958789.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://851958789.gitbook.io/notes/0135_candy/slt.md).

# Solution1 greedy

* 时间复杂度 O(n)
* 空间复杂度 O(n)

贪心不一定都要排序，这道题只需要从左往右一次，确保右边比较左边满足要求。

再右往左一次，确保左边比较右边满足要求。

从右往左是 alloc\[i] = max(alloc\[i], alloc\[i+1] + 1) 这样不破坏从左往右的性质
