반응형

시간 복잡도: O(N + M) --> 100%의 정답률

# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")

def solution(S, P, Q):
    # write your code in Python 3.6
    
    # step 1 - input array S,P,Q
    # already succeed
    
    # step 2 - get range from array P,Q
    M = len(P)
    
    return_arr = []
    
    # step 3 - do the job(for senetence)
    for i in range(M):
        arr = S[P[i]:Q[i]+1]
        try:
            arr.index('A')
            return_arr.append(1)
        except:
            try:
                arr.index('C')
                return_arr.append(2)
            except:
                try:
                    arr.index('G')
                    return_arr.append(3)
                except:
                    return_arr.append(4)
                    
    return return_arr
        
    pass
반응형

'Codility' 카테고리의 다른 글

Codility - PassingCars  (0) 2020.04.20
Codility - MinAvgTwoSlice  (0) 2020.04.19
Codility - CountDiv  (0) 2020.04.18
Codility - PermCheck  (0) 2020.04.18
Codility - MissingInteger  (0) 2020.04.17

+ Recent posts