Skip to content

Commit da0f4b7

Browse files
Merge pull request #1947 from CodingTestStudy2/변지협
[변지협] Day01
2 parents c958c6e + 6655417 commit da0f4b7

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'''
2+
1. 아이디어 :
3+
문제에 명시되어있는 것 그대로 구현한다.
4+
5+
2. 시간복잡도 :
6+
o(n^2)
7+
8+
3. 자료구조/알고리즘 :
9+
'''
10+
class Solution:
11+
def dominantIndices(self, nums: List[int]) -> int:
12+
n = len(nums)
13+
ans = 0
14+
for i in range(n-1):
15+
_sum = 0
16+
_len = n - i - 1
17+
print(i, _len)
18+
for j in range(i+1,n):
19+
_sum += nums[j]
20+
21+
avg = _sum / _len
22+
23+
if avg < nums[i]:
24+
ans +=1
25+
26+
return ans
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
'''
3+
1. 아이디어 :
4+
따지고 보면 먼저 돌을 가져가는 사람이 항상 이길 것이라고 생각이 들었음.
5+
선공이 짝수번째만 가져간다고 생각하면 짝수만 가져갈 수 있음. 홀수만 가져간다고 하면 홀수만 가져갈 수 있음.
6+
return True 하니까 답이라고 한다.
7+
8+
2. 시간복잡도 :
9+
o(1)
10+
11+
3. 자료구조/알고리즘 :
12+
'''
13+
class Solution:
14+
def stoneGame(self, piles: List[int]) -> bool:
15+
return True

0 commit comments

Comments
 (0)