Skip to content

Commit d45c35c

Browse files
committedJun 15, 2020
2020-06-14
1 parent 969df04 commit d45c35c

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution(object):
2+
def kidsWithCandies(self, candies, extraCandies):
3+
"""
4+
:type candies: List[int]
5+
:type extraCandies: int
6+
:rtype: List[bool]
7+
"""
8+
maxCandies = max(candies)
9+
return [curCandies + extraCandies >= maxCandies for curCandies in candies]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution(object):
2+
def maxDiff(self, num):
3+
"""
4+
:type num: int
5+
:rtype: int
6+
"""
7+
maxValues, minValues = float("-inf"), float("inf")
8+
s = str(num)
9+
for x in range(0, 10):
10+
for y in range(0, 10):
11+
val = s.replace(str(x), str(y))
12+
if val[0] != '0' and int(val) != 0:
13+
maxValues = max(maxValues, int(val))
14+
minValues = min(minValues, int(val))
15+
16+
return maxValues - minValues
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution(object):
2+
def checkIfCanBreak(self, s1, s2):
3+
"""
4+
:type s1: str
5+
:type s2: str
6+
:rtype: bool
7+
"""
8+
s1 = sorted(s1)
9+
s2 = sorted(s2)
10+
11+
return all(s1[i] >= s2[i] for i in range(len(s1))) or all(s2[i] >= s1[i] for i in range(len(s1)))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Solution(object):
2+
def destCity(self, paths):
3+
"""
4+
:type paths: List[List[str]]
5+
:rtype: str
6+
"""
7+
return (set(pair[1] for pair in paths) - set(pair[0] for pair in paths)).pop()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution(object):
2+
def kLengthApart(self, nums, k):
3+
"""
4+
:type nums: List[int]
5+
:type k: int
6+
:rtype: bool
7+
"""
8+
pre = None
9+
for i, num in enumerate(nums):
10+
if num == 1:
11+
if pre != None:
12+
if i - pre - 1 < k:
13+
return False
14+
pre = i
15+
return True

0 commit comments

Comments
 (0)