mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
update
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
],
|
||||
"companyTagStats": null,
|
||||
"codeSnippets": null,
|
||||
"stats": "{\"totalAccepted\": \"4K\", \"totalSubmission\": \"7.6K\", \"totalAcceptedRaw\": 3979, \"totalSubmissionRaw\": 7600, \"acRate\": \"52.4%\"}",
|
||||
"stats": "{\"totalAccepted\": \"4K\", \"totalSubmission\": \"7.6K\", \"totalAcceptedRaw\": 3985, \"totalSubmissionRaw\": 7616, \"acRate\": \"52.3%\"}",
|
||||
"hints": [
|
||||
"If we maintain DP(i, x) where i denotes the length and x denotes the last written integer (0 or 1), then it is not hard to solve in O(maxLength * max(zeroGroup, oneGroup)).",
|
||||
"Notice that from DP(i, 0) we only have a transition to DP(j, 1) where (j - i) mod oneGroup == 0 and j > i. Similarly with DP(i,1). So we can use prefix sum to optimize our DP and solve it in O(maxLength)."
|
||||
|
Reference in New Issue
Block a user