1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 23:41:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2023-12-09 19:57:46 +08:00
parent 9bc4722a45
commit 3770b44d1e
4792 changed files with 10889 additions and 10886 deletions

View File

@@ -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)."