# [월간 코드 챌린지] 풍선 터트리기

inkyu0103·2020년 9월 26일
0

### 1트

def solution(a):

for i in range(len(a)):
if i == 0 :
min(a[1:])>a[i]
elif i == len(a)-1:
min(a[:i+1])>a[i]

else:
if min(a[:i]) < a[i] and min(a[i+1:]) < a[i]:
continue
else:
return answer

### 2트

def solution(a):
l = len(a)

if l == 1 or l == 2:
return l

else:
pre_min_idx = 0
suf_min_idx = a.index(min(a[2:]))

for i in range(1,l-1):
RF , LF = 0 , 0

if i == suf_min_idx:
suf_min_idx = a.index(min(a[i+1:]))

if a[pre_min_idx] < a[i]:
LF = 1

if a[suf_min_idx] < a[i]:
RF = 1

if a[pre_min_idx] > a[i] :
pre_min_idx = i

if a[suf_min_idx] > a[i]:
suf_min_idx = a.index(min(a[i+1:]))

if (RF ==1  and LF == 1):
pass
else:

return answer

### 3트

def solution(a):
if len(a)<=2 :
return len(a)

else:
left_memo = []
right_memo = []

#왼쪽 -> 오른쪽
left_min_idx = 0
for i in range(1,len(a)-1):
if a[left_min_idx] < a[i]:
left_memo.append((i,True))
else:
left_memo.append((i,False))
left_min_idx = i

#오른쪽 -> 왼쪽
right_min_idx = len(a)-1
for j in range(len(a)-2,0,-1):
if a[right_min_idx] < a[j]:
right_memo.append((j,True))
else:
right_memo.append((j,False))
right_min_idx = j
right_memo.sort()

#확인
for i in range(0, len(left_memo)):
if left_memo[i][1] and right_memo[i][1]:
pass
else:
return answer