-
GenomicRangeQueryStudy/알고리즘 2018. 1. 15. 10:56
1차 풀이
일단 정답맞나 확인용으로 풀어봄..
public static int[] solution(String S, int[] P, int[] Q){ int result[] = new int[P.length]; for(int i = 0 ; i < P.length; i++){ int start = P[i]; int end = Q[i]; String temp = S.substring(start, end+1); char charArray[] = temp.toCharArray(); int min = 0; for(int j = 0; j < charArray.length; j++){ int tempChar = 0; switch (charArray[j]){ case 'A': tempChar = 1; break; case 'C': tempChar = 2; break; case 'G': tempChar = 3; break; case 'T': tempChar = 4; break; } if(min == 0 || min > tempChar ){ min = tempChar; } } result[i] = min; } return result; }
https://app.codility.com/demo/results/training92WETS-JK2/
이제 퍼포먼스를 올려 볼까..
'Study > 알고리즘' 카테고리의 다른 글
NumberOfDiscIntersections (0) 2018.01.16 MaxProductOfThree (0) 2018.01.16 Distinct (0) 2018.01.15 Triangle (0) 2018.01.15 MinAvgTwoSlice (0) 2018.01.15 PassingCars (0) 2018.01.12 CountDiv (0) 2018.01.12 MaxCounters (0) 2018.01.12 MissingInteger (0) 2018.01.12 FrogRiverOne (0) 2018.01.12 댓글