Skip to content

Commit

Permalink
chlng and easy prob 24.01
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriSpiridonov committed Jan 24, 2021
1 parent 609207c commit e32e447
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
1 change: 1 addition & 0 deletions Challenges/2021/January-LeetCoding-Challenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ None
| ----: | --- | --- | --- |
|1657.|[Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close/)|[Python](/Medium/1657.DetermineifTwoStringsAreClose.py)|Medium|
|1329.|[Sort the Matrix Diagonally](https://leetcode.com/problems/sort-the-matrix-diagonally/)|[Python](/Medium/1329.SorttheMatrixDiagonally.py)|Medium|
|23.|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/)|[Python](/Hard/23.MergekSortedLists.py)|Hard|

## License
The code is open-source and licensed under the [MIT License](/LICENSE).
2 changes: 1 addition & 1 deletion Challenges/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
- [December LeetCoding Challenge](/Challenges/2020/December-LeetCoding-Challenge.md) - 27/31

2021:
- [January LeetCoding Challenge](/Challenges/2021/January-LeetCoding-Challenge.md) - 21/31
- [January LeetCoding Challenge](/Challenges/2021/January-LeetCoding-Challenge.md) - 22/31
43 changes: 43 additions & 0 deletions Easy/1732.FindtheHighestAltitude.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'''
There is a biker going on a road trip. The road trip
consists of n + 1 points at different altitudes. The
biker starts his trip on point 0 with altitude equal 0.
You are given an integer array gain of length n where
gain[i] is the net gain in altitude between points i​​​​​​ and
i + 1 for all (0 <= i < n). Return the highest altitude
of a point.
Example:
Input: gain = [-5,1,5,0,-7]
Output: 1
Explanation: The altitudes are [0,-5,-4,1,1,-6]. The
highest is 1.
Example:
Input: gain = [-4,-3,-2,-1,4,3,2]
Output: 0
Explanation: The altitudes are [0,-4,-7,-9,-10,-6,-3,-1].
The highest is 0.
Constraints:
- n == gain.length
- 1 <= n <= 100
- -100 <= gain[i] <= 100
'''
#Difficulty: Easy
#80 / 80 test cases passed.
#Runtime: 32 ms
#Memory Usage: 14.3 MB

#Runtime: 32 ms, faster than 100.00% of Python3 online submissions for Find the Highest Altitude.
#Memory Usage: 14.3 MB, less than 100.00% of Python3 online submissions for Find the Highest Altitude.

class Solution:
def largestAltitude(self, gain: List[int]) -> int:
current_height = 0
height = 0
for g in gain:
current_height += g
height = max(height, current_height)
return height
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Python solutions of LeetCode problems.
![Language](https://img.shields.io/badge/language-Python-blue.svg)&nbsp;
![Problems Solved](https://img.shields.io/badge/problems%20solved-500%2F1571-orange)&nbsp;
![Problems Solved](https://img.shields.io/badge/problems%20solved-501%2F1571-orange)&nbsp;
[![License](https://img.shields.io/badge/license-MIT-green.svg)](./LICENSE)&nbsp;
![Update](https://img.shields.io/badge/update-Daily-brightgreen.svg)&nbsp;
<br><br>
Expand All @@ -19,7 +19,7 @@ In this repository provided my Python solutions of LeetCode problems.
- [December LeetCoding Challenge](/Challenges/2020/December-LeetCoding-Challenge.md) - 27/31

2021:
- [January LeetCoding Challenge](/Challenges/2021/January-LeetCoding-Challenge.md) - 21/31
- [January LeetCoding Challenge](/Challenges/2021/January-LeetCoding-Challenge.md) - 22/31
<br><br>
## Solutions
*P.S. If you like this, please leave me a star.*
Expand Down Expand Up @@ -545,6 +545,7 @@ In this repository provided my Python solutions of LeetCode problems.
|1720.|[Decode XORed Array](https://leetcode.com/problems/decode-xored-array/)|[Python](/Easy/1720.DecodeXORedArray.py)|Easy||
|1721.|[Swapping Nodes in a Linked List](https://leetcode.com/problems/swapping-nodes-in-a-linked-list/)|[Python](/Medium/1721.SwappingNodesinaLinkedList.py)|Medium|`Linked List`, `Queue`|
|1725.|[Number Of Rectangles That Can Form The Largest Square](https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/)|[Python](/Easy/1725.NumberOfRectanglesThatCanFormTheLargestSquare.py)|Easy|`collections.defaultdict`|
|1732.|[Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude/)|[Python](/Easy/1732.FindtheHighestAltitude.py)|Easy||

<div align="right">
<b><a href="#python-solutions-of-leetcode-problems">Back to Top</a></b>
Expand Down

0 comments on commit e32e447

Please sign in to comment.