python CPP DP動態規劃速解難題Leetcode 552 Student Attendance Record II
Leetcode 552. Student Attendance Record II為什麼是難題?原來@cache這招會導致MLE。先用動態規劃解,因為參數只有一個,當然還有更快的Matrix power解法
Leetcode 552. Why is Student Attendance Record II a hard problem? It turns out that @cache's trick will cause MLE. Use dynamic programming to solve it first, because there is only one parameter, and of course there is a faster solution, i.e. using matrix power.
[codes on Leetcode]https://leetcode.com/problems/student-attendance-record-ii/solutions/5208681/dp-recursion-memo-tabular-space-optimized-vs-matrix-power-o-log-n-3ms-beats-99-38/
[Dynamic programming playlist]https://www.youtube.com/watch?v=30yq3fmE6E8&list=PLYRlUBnWnd5K_XYUesV9oc6M9ONXII61T
[Leetcode Playlist]https://www.youtube.com/watch?v=B1GQlUN08lk&list=PLYRlUBnWnd5IdDHk2BjqXwesydU17z_xk
[Fibonacci sequence playlist]https://www.youtube.com/watch?v=30yq3fmE6E8&list=PLYRlUBnWnd5Jb9PI7P1V2GEgOu1n3hki-
沒有留言:
張貼留言