Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Updated solution for 1307 and added solution for 1354. #1823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nrhitik wants to merge 20 commits into doocs:main from nrhitik:main
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ef6cff5
Added Solution for 1912. Movie Rental System in python.
nrhitik Oct 14, 2023
ca705c1
Update README.md
yanglbme Oct 15, 2023
727bd2c
Update README_EN.md
yanglbme Oct 15, 2023
d1241ab
Update Solution.py
yanglbme Oct 15, 2023
5ac39c3
Merge branch 'doocs:main' into main
nrhitik Oct 15, 2023
a02c409
Solution for 1900. Earliest and Latest Rounds Where Players Compete.
nrhitik Oct 15, 2023
c530b16
Merge branch 'main' into main
nrhitik Oct 15, 2023
24457d6
Merge branch 'main' into main
nrhitik Oct 16, 2023
11ee104
Merge branch 'doocs:main' into main
nrhitik Oct 16, 2023
dd85b2c
Added Solution for 1307. Verbal Arithmetic Puzzel and Updated README....
nrhitik Oct 16, 2023
cce5b39
Added solution for 1354.
nrhitik Oct 16, 2023
1ba8be6
Merge branch 'main' into main
nrhitik Oct 16, 2023
b1d5882
Updated solution for 1307 to pass all the test cases.
nrhitik Oct 16, 2023
aa585c8
Merge branch 'main' of https://github.com/nrhitik/leetcode
nrhitik Oct 16, 2023
ea51913
Updated README for 1307.
nrhitik Oct 16, 2023
9d9cc9b
Merge branch 'main' into main
nrhitik Oct 17, 2023
f06d35e
Merge branch 'main' into main
nrhitik Oct 17, 2023
68821c3
Removed solution for 1307.
nrhitik Oct 18, 2023
00027e9
Merge branch 'main' of https://github.com/nrhitik/leetcode
nrhitik Oct 18, 2023
45b34c5
Merge branch 'main' into main
nrhitik Oct 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,29 @@
<!-- 这里可写当前语言的特殊实现逻辑 -->

```python
class Solution:
def isPossible(self, target: List[int]) -> bool:
if len(target) == 1:
return target[0] == 1

summ = sum(target)
maxHeap = [-num for num in target]
heapq.heapify(maxHeap)

while -maxHeap[0] > 1:
maxi = -heapq.heappop(maxHeap)
restSum = summ - maxi
# Only occurs if n == 2.
if restSum == 1:
return True
updated = maxi % restSum
# Updated == 0 (invalid) or didn't change.
if updated == 0 or updated == maxi:
return False
heapq.heappush(maxHeap, -updated)
summ = summ - maxi + updated

return True

```

Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,29 @@
### **Python3**

```python
class Solution:
def isPossible(self, target: List[int]) -> bool:
if len(target) == 1:
return target[0] == 1

summ = sum(target)
maxHeap = [-num for num in target]
heapq.heapify(maxHeap)

while -maxHeap[0] > 1:
maxi = -heapq.heappop(maxHeap)
restSum = summ - maxi
# Only occurs if n == 2.
if restSum == 1:
return True
updated = maxi % restSum
# Updated == 0 (invalid) or didn't change.
if updated == 0 or updated == maxi:
return False
heapq.heappush(maxHeap, -updated)
summ = summ - maxi + updated

return True

```

Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Solution:
def isPossible(self, target: List[int]) -> bool:
if len(target) == 1:
return target[0] == 1

summ = sum(target)
maxHeap = [-num for num in target]
heapq.heapify(maxHeap)

while -maxHeap[0] > 1:
maxi = -heapq.heappop(maxHeap)
restSum = summ - maxi
# Only occurs if n == 2.
if restSum == 1:
return True
updated = maxi % restSum
# Updated == 0 (invalid) or didn't change.
if updated == 0 or updated == maxi:
return False
heapq.heappush(maxHeap, -updated)
summ = summ - maxi + updated

return True

AltStyle によって変換されたページ (->オリジナル) /