Count the number of Duplicates Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits. Example "abcde" -> 0 # no characters repeats more than once "aabbcde" -> 2 # 'a' and 'b' "aabBcde..
Task You will be given an array of numbers. You have to sort the odd numbers in ascending order while leaving the even numbers at their original positions. Examples [7, 1] => [1, 7] [5, 8, 6, 3, 4] => [3, 8, 6, 5, 4] [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] => [1, 8, 3, 6, 5, 4, 7, 2, 9, 0] function sortArray(array) { const result = array.filter((a)=> a%2 !== 0) result.sort(function(a,b){ return a-b }); c..
Instructions In a small town the population is p0 = 1000 at the beginning of a year. The population regularly increases by 2 percent per year and moreover 50 new inhabitants per year come to live in the town. How many years does the town need to see its population greater or equal to p = 1200 inhabitants? At the end of the first year there will be: 1000 + 1000 * 0.02 + 50 => 1070 inhabitants At ..
Description: Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 positive integers. No floats or non-positive integers will be passed. For example, when an array is passed like [19, 5, 42, 2, 77], the output should be 7. [10, 343445353, 3453445, 3453545353453] should return 3453455. function sumTwoSmallestNumbers(numbers) { const sortArray = numb..
평균은 넘겠지 문제 대학생 새내기들의 90%는 자신이 반에서 평균은 넘는다고 생각한다. 당신은 그들에게 슬픈 진실을 알려줘야 한다. 입력 첫째 줄에는 테스트 케이스의 개수 C가 주어진다. 둘째 줄부터 각 테스트 케이스마다 학생의 수 N(1 ≤ N ≤ 1000, N은 정수)이 첫 수로 주어지고, 이어서 N명의 점수가 주어진다. 점수는 0보다 크거나 같고, 100보다 작거나 같은 정수이다. 출력 각 케이스마다 한 줄씩 평균을 넘는 학생들의 비율을 반올림하여 소수점 셋째 자리까지 출력한다. 예제 입력 1 복사 5 5 50 50 70 80 100 7 100 95 90 80 70 60 50 3 70 90 80 3 70 90 81 9 100 99 98 97 96 95 94 93 91 예제 출력 1 복사 40.000..

Big O란? 알고리즘의 퍼포먼스를 이해하기 쉽고 효율적으로 작성하는 방식 Sorting은 A-Z까지 정렬하거나 큰수에서 작은수, 이진 검색처럼 빠른 알고리즘을 사용하려면 일단 먼저 배열 정렬을 해야한다. 1. 버블정렬 장점 : 쉬움 단점 : 자주 사용되지는 않음 두개의 아이템을 비교하고 오른쪽으로 반복해서 이동하는 방법으로 비교하고 스와핑의 반복이다. Big O ⇒ 최악의 경우 모든 수를 다 스왑해야한다. 따라서 모든 사이클 마다 아이템을 교환해야해서 O(n^2)이다. 2. 선택정렬 전체 아이템중에서 가장 작은 아이템의 위치를 정하고 그 위치를 변수에 저장한다. 앞에서 부터 비교해 나가면서 지정해둔 가장 작은 숫자보다 크면 가장 작은 아이템의 위치의 수와 스왑한다. 그리고 처음 스왑해서 위치가 저장된 ..