Skip to content

Commit 9f2fd93

Browse files
Merge pull request #1643 from CodingTestStudy2/최원준
[최원준] Day08
2 parents 109bd77 + d54b2b7 commit 9f2fd93

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
3+
'''
4+
1. 아이디어 :
5+
-
6+
7+
2. 시간복잡도 :
8+
O(n-2)
9+
10+
3. 자료구조/알고리즘 :
11+
-
12+
13+
'''
14+
class Solution:
15+
def countSubarrays(self, nums: List[int]) -> int:
16+
n = len(nums)
17+
ans = 0
18+
for i in range(n-2):
19+
if (nums[i] + nums[i+2]) * 2== nums[i+1]:
20+
ans+=1
21+
return ans
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
3+
'''
4+
1. 아이디어 :
5+
i가 아닌부분(a), i인 부분(b)를 나눠서 계산
6+
7+
2. 시간복잡도 :
8+
O(1)
9+
10+
3. 자료구조/알고리즘 :
11+
-
12+
13+
'''
14+
class Solution:
15+
def complexNumberMultiply(self, num1: str, num2: str) -> str:
16+
17+
def parse_and_remove(num: str) -> list:
18+
num = num.split("+")
19+
num[0] = int(num[0])
20+
num[1] = int(num[1][:-1])
21+
return num
22+
23+
num1 = parse_and_remove(num1)
24+
num2 = parse_and_remove(num2)
25+
26+
not_i = num1[0] * num2[0] - num1[1] * num2[1]
27+
i = num1[0] * num2[1] + num1[1] * num2[0]
28+
29+
return str(not_i) + "+" + str(i) + "i"
30+
31+
32+

0 commit comments

Comments
 (0)