Categorygithub.com/szhou12/leetcode-goleetcode2305-Fair-Distribution-of-Cookies
package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev

# README

2305. Fair Distribution of Cookies

Solution idea

DFS

DFS暴力解

每一层是当前cookie。 每一个分支是一个人,总共k个分支。

Time complexity = $O(k^n)$

Binary Search + DFS

思路: 如果直接找答案 (DFS暴力解) 不够efficient,那么,就反其道而行之,猜答案.

猜答案的方法:Binary Search - 对每个人最多能拿到的数量进行猜测,如果当前数量可行,可能是答案,再往低了猜。

Resource

【每日一题】LeetCode 2305. Fair Distribution of Cookies