파이썬 코딩테스트 준비(16)
-
[Python 문제풀이] 7일차
Day_7 Intro. Q12. Sort by Height Some people are standing in a row in a park. There are trees between them which cannot be moved. Your task is to rearrange the people by their heights in a non-descending order without moving the trees. People can be very tall! def sortByHeight(a): IdxSet_minus1 = [] sort_a = [] cnt_minus1 = 0 cnt_sort = 0 for i in range(len(a)): if a[i] == -1: IdxSet_minus1.appe..
2020.07.15 -
[Python 문제풀이] 5일차
Day_5 Q10. commonCharacterCount Given two strings, find the number of common characters between them. def commonCharacterCount(s1, s2): s3 = list(s1) s4 = list(s2) save = list() if len(s3) >= len(s4): for i in range(len(s4)): Character = s4[i] try: Idx = s3.index(Character) except: pass else: save.append(s3.pop(Idx)) else: for i in range(len(s3)): Character = s3[i] try: Idx = s4.index(Character)..
2020.07.13 -
[Python 문제풀이] 4일차
Day_4 Q9. allLongestStrings Given an array of strings, return another array containing all of its longest strings. def allLongestStrings(inputArray): maxLen = 0 for word in inputArray: if maxLen < len(word): maxLen = len(word) maxLenList = list() for word in inputArray: if len(word) == maxLen: maxLenList.append(word) return maxLenList 오늘부턴 코드 짜는 과정도 메모해둘 수 있으면 메모해서 올리자 # 문제 파악 # Given an array o..
2020.07.12 -
[Python 문제풀이] 3일차
Day_3 Q8. matrixElementSum After becoming famous, the CodeBots decided to move into a new building together. Each of the rooms has a different cost, and some of them are free, but there's a rumour that all the free rooms are haunted! Since the CodeBots are quite superstitious, they refuse to stay in any of the free rooms, or any of the rooms below any of the free rooms. Given matrix, a recta..
2020.07.11