Maximum Number Of Points With Cost - #159
Open
tom4649 wants to merge 1 commit into
Open
Conversation
oda
reviewed
Aug 15, 2026
|
|
||
| ## step1 | ||
|
|
||
| dp を使えそうだと思った。計算量 O(mn^2) の解法しか思いつかず、TLE した解法: step1_TLE.py |
There was a problem hiding this comment.
思いつき方ですが、計算量 O(mn^2) は、まずできるとして、
計算量の形から2行でも、O(mn) か log つくくらいでできると言っています。
2行の場合ができたら、fold すればいいので2行の場合だけを考えればいいです。
これを線形時間で対応を取れるかですが、左向きに走査と右向きに走査を組み合わせればできそうですね。
類題: Trapping Rain Water
#124
nodchip
reviewed
Aug 15, 2026
| num_rows = len(points) | ||
| num_cols = len(points[0]) | ||
|
|
||
| dp_prev = points[0][:] |
There was a problem hiding this comment.
こちらのコメントをご参照ください。
Yuto729/leetcode#105 (comment)
今回の場合ですと、 previous_max_points あたりが良いと思います。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://leetcode.com/problems/maximum-number-of-points-with-cost/description/?envType=problem-list-v2&envId=7p55wqm