javascript

    [JS] 타입 변환과 단축 평가

    스터디 자료: https://poiemaweb.com/js-type-coercion 9. 타입 변환과 단축 평가 명시적 타입 변환(타입 캐스팅) 개발자에 의해 의도적으로 값의 타입을 변환 var x = 10; // 명시적 타입 변환 var str = x.toString(); // 숫자를 문자열로 타입 캐스팅한다. console.log(typeof str); // string 암묵적 타입 변환(타입 강제 변환) 동적 타입 언어인 자바스크립트는 개발자의 의도와는 상관없이 자바스크립트 엔진에 의해 암묵적으로 타입이 자동 변환되기도 한다. var x = 10; // 암묵적 타입 변환 // 숫자 타입 x의 값을 바탕으로 새로운 문자열 타입의 값을 생성해 표현식을 평가한다. var str = x + ''; cons..

    코딜리티 - Brackets (javascript)

    Task description A string S consisting of N characters is considered to be properly nested if any of the following conditions is true: S is empty; S has the form "(U)" or "[U]" or "{U}" where U is a properly nested string; S has the form "VW" where V and W are properly nested strings. For example, the string "{[()()]}" is properly nested but "([)()]" is not. Write a function: function solution(S..

    코딜리티 - MissingInteger (javascript)

    Task description This is a demo task. Write a function: function solution(A); that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5. Given A = [1, 2, 3], the function should return 4. Given A = [−1, −3], the function should return 1. Write an efficient algorith..

    코딜리티 - GenomicRangeQuery (javascript)

    Task description A DNA sequence can be represented as a string consisting of the letters A, C, G and T, which correspond to the types of successive nucleotides in the sequence. Each nucleotide has an impact factor, which is an integer. Nucleotides of types A, C, G and T have impact factors of 1, 2, 3 and 4, respectively. You are going to answer several queries of the form: What is the minimal im..

    코딜리티 FrogRiverOne (javascript)

    Task description A small frog wants to get to the other side of a river. The frog is initially located on one bank of the river (position 0) and wants to get to the opposite bank (position X+1). Leaves fall from a tree onto the surface of the river. You are given an array A consisting of N integers representing the falling leaves. A[K] represents the position where one leaf falls at time K, meas..

    코딜리티 - Dominator (javascript)

    Task description An array A consisting of N integers is given. The dominator of array A is the value that occurs in more than half of the elements of A. For example, consider array A such that A[0] = 3 A[1] = 4 A[2] = 3 A[3] = 2 A[4] = 3 A[5] = -1 A[6] = 3 A[7] = 3 The dominator of A is 3 because it occurs in 5 out of 8 elements of A (namely in those with indices 0, 2, 4, 6 and 7) and 5 is more ..