698. Partition to K Equal Sum Subsets

refer this!

https://mp.weixin.qq.com/s?__biz=MzAxODQxMDM0Mw==&mid=2247490981&idx=1&sn=db17864d2f6f189d63e051e434c05460&scene=21#wechat_redirect

經典題目

from bucket view

T: O(k*2^n)

S: O(n)

We have used an extra array of size N to mark the already used elements.

And the recursive tree makes at most N calls at one time, so the recursive stack also takes O(N) space

from numbers view

T: O(k^n), with pruning beats 92%

S: O(n)

Last updated

Was this helpful?