-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from AlgoLeadMe/6-kjs254
6-kjs254
- Loading branch information
Showing
4 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def dfs(my_word): | ||
global dic | ||
vowel = ['A','E','I','O','U'] | ||
|
||
if len(my_word)<=5: | ||
dic.append(my_word) | ||
|
||
for v in vowel: | ||
dfs(my_word + v) | ||
|
||
def solution(word): | ||
global dic | ||
dic = [] | ||
dfs('') | ||
answer = dic.index(word) | ||
return answer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
def func(bracket): | ||
stk = [] | ||
for b in bracket: | ||
if b in ["[","{","("]: | ||
stk.append(b) | ||
elif b in ["]","}",")"]: | ||
if not stk: | ||
return False | ||
if stk[-1]=="[" and b=="]": | ||
stk.pop() | ||
elif stk[-1]=="{" and b=="}": | ||
stk.pop() | ||
elif stk[-1]=="(" and b==")": | ||
stk.pop() | ||
else: | ||
return False | ||
return not stk | ||
|
||
def solution(s): | ||
answer = 0 | ||
l = len(s) | ||
for i in range(l): | ||
x = s[i:]+s[:i] | ||
if func(x): | ||
answer +=1 | ||
|
||
return answer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from collections import deque | ||
|
||
def solution(people, limit): | ||
answer = 0 | ||
people = deque(sorted(people)) | ||
|
||
while len(people)>1: | ||
if people[0]+people[-1]<=limit: | ||
people.pop() | ||
people.popleft() | ||
answer+=1 | ||
else: | ||
people.pop() | ||
answer+=1 | ||
|
||
return answer+1 if people else answer |