Skip to content

Commit aaf1e45

Browse files
committed
2019-07-13
1 parent 3a750f0 commit aaf1e45

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution(object):
2+
def numberOfDays(self, Y, M):
3+
"""
4+
:type Y: int
5+
:type M: int
6+
:rtype: int
7+
"""
8+
9+
if (Y % 100 != 0 and Y % 4 ==0) or (Y % 100 == 0 and Y % 400 == 0) :
10+
return [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][M - 1]
11+
else:
12+
return [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][M - 1]
13+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution(object):
2+
def removeVowels(self, S):
3+
"""
4+
:type S: str
5+
:rtype: str
6+
"""
7+
res = ""
8+
for char in S:
9+
if char not in "aeiou":
10+
res += char
11+
12+
return res
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Definition for a binary tree node.
2+
# class TreeNode(object):
3+
# def __init__(self, x):
4+
# self.val = x
5+
# self.left = None
6+
# self.right = None
7+
8+
class Solution(object):
9+
def maximumAverageSubtree(self, root):
10+
"""
11+
:type root: TreeNode
12+
:rtype: float
13+
"""
14+
if not root:
15+
return 0
16+
17+
def inorder(node):
18+
if not node:
19+
return []
20+
return inorder(node.left) + [node.val] + inorder(node.right)
21+
22+
Inorder = inorder(root)
23+
return max(1.0 * sum(Inorder) / len(Inorder), self.maximumAverageSubtree(root.left), self.maximumAverageSubtree(root.right))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution(object):
2+
def canDivideIntoSubsequences(self, nums, K):
3+
"""
4+
:type nums: List[int]
5+
:type K: int
6+
:rtype: bool
7+
"""
8+
if len(nums) < K:
9+
return False
10+
from collections import Counter
11+
d = Counter(nums)
12+
maxx = 1
13+
for key, val in d.items():
14+
maxx = max(val, maxx)
15+
16+
return maxx * K <= len(nums)

0 commit comments

Comments
 (0)