본문 바로가기

728x90

전체 글

(104)
lv.1 - K번째수 문제 설명 배열 array의 i번째 숫자부터 j번째 숫자까지 자르고 정렬했을 때, k번째에 있는 수를 구하려 합니다. 예를 들어 array가 [1, 5, 2, 6, 3, 7, 4], i = 2, j = 5, k = 3이라면 array의 2번째부터 5번째까지 자르면 [5, 2, 6, 3]입니다. 1에서 나온 배열을 정렬하면 [2, 3, 5, 6]입니다. 2에서 나온 배열의 3번째 숫자는 5입니다. 배열 array, [i, j, k]를 원소로 가진 2차원 배열 commands가 매개변수로 주어질 때, commands의 모든 원소에 대해 앞서 설명한 연산을 적용했을 때 나온 결과를 배열에 담아 return 하도록 solution 함수를 작성해주세요. 제한 조건 array의 길이는 1 이상 100 이하입니다. ..
26401. JSONSchema2TS 문제 Implement the generic type JSONSchema2TS which will return the TypeScript type corresponding to the given JSON schema. cases // + Primitive types type Type1 = JSONSchema2TS type Expected1 = string type Result1 = Expect type Type2 = JSONSchema2TS type Expected2 = number type Result2 = Expect type Type3 = JSONSchema2TS type Expected3 = boolean type Result3 = Expect // - Primitive types // + Enu..
25270. Transpose 문제 The transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix A by producing another matrix, often denoted by AT. type Matrix = Transpose ; // expected to be [[1]] type Matrix1 = Transpose ; // expected to be [[1, 3], [2, 4]] type Matrix2 = Transpose ; // expected to be [[1, 4], [2, 5], [3, 6]] cases type cases =..
25170. ReplaceFirst 문제 Implement the type ReplaceFirst which will replace the first occurrence of S in a tuple T with R. If no such S exists in T, the result should be T. cases type cases = [ Expect, Expect, Expect, Expect, Expect, Expect, ] 문제 링크 정답 type ReplaceFirst = T extends [infer T1, ...infer Rest] ? T1 extends S ? [R, ...Rest] : [T1, ...ReplaceFirst] : [] 풀이 조건 T의 요소 중 처음 나오는 S를 R로 교체한 후 T를 반환한다. T에 S가 없는 경..
21220. PermutationsOfTuple 문제 Given a generic tuple type T extends unknown[], write a type which produces all permutations of T as a union. PermutationsOfTuple /** * Should return: * | [1, number, unknown] * | [1, unknown, number] * | [number, 1, unknown] * | [unknown, 1, number] * | [number, unknown, 1] * | [unknown, number ,1] */ cases type cases = [ Expect, Expect, Expect, Expect>, Expect>, ExpectFalse, ] 문제 링크 정답 type..
lv.1 - 완주하지 못한 선수 문제 설명 수많은 마라톤 선수들이 마라톤에 참여하였습니다. 단 한 명의 선수를 제외하고는 모든 선수가 마라톤을 완주하였습니다. 마라톤에 참여한 선수들의 이름이 담긴 배열 participant와 완주한 선수들의 이름이 담긴 배열 completion이 주어질 때, 완주하지 못한 선수의 이름을 return 하도록 solution 함수를 작성해주세요. 제한 조건 마라톤 경기에 참여한 선수의 수는 1명 이상 100,000명 이하입니다. completion의 길이는 participant의 길이보다 1 작습니다. 참가자의 이름은 1개 이상 20개 이하의 알파벳 소문자로 이루어져 있습니다. 참가자 중에는 동명이인이 있을 수 있습니다. 입출력 예 participant completion return ["leo", "ki..
21106. Combs 문제 Combine multiple modifier keys, but the same modifier key combination cannot appear. In the ModifierKeys provided, the priority of the previous value is higher than the latter value; that is, cmd ctrl is OK, but ctrl cmd is not allowed. cases type ModifierKeys = ['cmd', 'ctrl', 'opt', 'fn'] type CaseTypeOne = 'cmd ctrl' | 'cmd opt' | 'cmd fn' | 'ctrl opt' | 'ctrl fn' | 'opt fn' type cases = [..
18220. Filter 문제 Implement the type Filter takes an Array T, primitive type or union primitive type Predicate and returns an Array include the elements of Predicate. cases type Falsy = false | 0 | '' | null | undefined type cases = [ Expect, Expect, Expect, ] 문제 링크 정답 type Filter = T extends [infer T1, ...infer Rest] ? T[0] extends P ? [T1, ...Filter] : Filter : [] 풀이 조건 P에 포함된 요소만 필터링해서 배열 형태로 출력한다. 해설 T의 요소..

728x90