Skip to content

Commit

Permalink
Dec 27
Browse files Browse the repository at this point in the history
  • Loading branch information
siddydutta committed Dec 29, 2024
1 parent c6e9744 commit 27c5cf0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 22 additions & 0 deletions 2024-12-December-LeetCoding-Challenge/Best Sightseeing Pair.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from typing import List


class Solution:
def maxScoreSightseeingPair(self, values: List[int]) -> int:
max_so_far, result = values[0], 0
for i in range(1, len(values)):
result = max(result, max_so_far+values[i]-i)
max_so_far = max(max_so_far, values[i]+i)
return result


def main():
values = [8, 1, 5, 2, 6]
assert Solution().maxScoreSightseeingPair(values) == 11

values = [1, 2]
assert Solution().maxScoreSightseeingPair(values) == 2


if __name__ == '__main__':
main()
4 changes: 2 additions & 2 deletions 2024-12-December-LeetCoding-Challenge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
| December 24 | [3203. Find Minimum Diameter After Merging Two Trees](https://leetcode.com/problems/find-minimum-diameter-after-merging-two-trees/) | Hard | Unsolved |
| December 25 | [515. Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row/) | Medium | Solved |
| December 26 | [494. Target Sum](https://leetcode.com/problems/target-sum/) | Medium | Solved |
| December 27 | []() | | |
| December 27 | [1014. Best Sightseeing Pair](https://leetcode.com/problems/best-sightseeing-pair/) | Medium | Unsolved |
| December 28 | []() | | |
| December 29 | []() | | |
| December 30 | []() | | |
Expand All @@ -39,5 +39,5 @@
| Level | Problems | Solved | Unsolved |
| --- | --- | --- | --- |
| Easy | 5 | 5 | 0 |
| Medium | 18 | 12 | 6 |
| Medium | 19 | 12 | 7 |
| Hard | 3 | 0 | 3 |

0 comments on commit 27c5cf0

Please sign in to comment.