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 이하입니다. ..
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..