목록javascript (23)
kohigowild

Count Largest Group You are given an integer n. Each number from 1 to n is grouped according to the sum of its digits. Return the number of groups that have the largest size. Example 1: Input: n = 13 Output: 4 Explanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13: [1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. There are 4 groups ..

Reverse Vowels of a String Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper cases, more than once. Example 1: Input: s = "hello" Output: "holle" Example 2: Input: s = "leetcode" Output: "leotcede" Constraints: 1

Apply Operations to an Array You are given a 0-indexed array nums of size n consisting of non-negative integers. You need to apply n - 1 operations to this array where, in the ith operation (0-indexed), you will apply the following on the ith element of nums: If nums[i] == nums[i + 1], then multiply nums[i] by 2 and set nums[i + 1] to 0. Otherwise, you skip this operation. After performing all t..

Best Time to Buy and Sell Stock You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. Example 1: Input: prices = ..

문자열 내 마음대로 정렬하기 👾 문제 설명 문자열로 구성된 리스트 strings와, 정수 n이 주어졌을 때, 각 문자열의 인덱스 n번째 글자를 기준으로 오름차순 정렬하려 합니다. 예를 들어 strings가 ["sun", "bed", "car"]이고 n이 1이면 각 단어의 인덱스 1의 문자 "u", "e", "a"로 strings를 정렬합니다. 👾 제한 사항 strings는 길이 1 이상, 50이하인 배열입니다. strings의 원소는 소문자 알파벳으로 이루어져 있습니다. strings의 원소는 길이 1 이상, 100이하인 문자열입니다. 모든 strings의 원소의 길이는 n보다 큽니다. 인덱스 1의 문자가 같은 문자열이 여럿 일 경우, 사전순으로 앞선 문자열이 앞쪽에 위치합니다. 👾 나의 답안 funct..

Project 1) 프로젝트 기간: 2022.10.15 ~ 2022.10.22 2) 수강한 강의: https://nomadcoders.co/javascript-for-beginners/lobby 바닐라 JS로 크롬 앱 만들기 – 노마드 코더 Nomad Coders Javascript For Beginners nomadcoders.co 3) Project Link github: https://github.com/trustmitt/cloneMomentumApp GitHub - trustmitt/cloneMomentumApp Contribute to trustmitt/cloneMomentumApp development by creating an account on GitHub. github.com page: ..

N개의 최소공배수 👾 문제 설명 두 수의 최소공배수(Least Common Multiple)란 입력된 두 수의 배수 중 공통이 되는 가장 작은 숫자를 의미합니다. 예를 들어 2와 7의 최소공배수는 14가 됩니다. 정의를 확장해서, n개의 수의 최소공배수는 n 개의 수들의 배수 중 공통이 되는 가장 작은 숫자가 됩니다. n개의 숫자를 담은 배열 arr이 입력되었을 때 이 수들의 최소공배수를 반환하는 함수, solution을 완성해 주세요. 👾 제한 사항 arr은 길이 1이상, 15이하인 배열입니다. arr의 원소는 100 이하인 자연수입니다. 💬 참고 a, b에 대하여 a * b = gcd(a, b) * lcm (a, b)이다. 즉, a * b의 값을 gcd(a, b)로 나누면 lcm(a, b)의 값이 나..

🧐 프로토타입이란? 일반적으로 프로토타입(prototype)이란 원형이라는 뜻을 가진다. 자바스크립트는 프로토타입 기반 언어이다. 모든 객체들이 메서드와 속성들을 상속 받기 위한 템플릿으로써 프로토타입 객체를 가진다는 의미다. 우리가 함수라는 객체를 생성했을 때 그 객체에는 prototype이라는 object가 자동으로 생성된다. prototype에는 다시 constructor라는 객체가 자동으로 생성되어 서로를 참조할 수 있게 된다. Person.prototype.sum = function(){} 위의 코드를 통해서 prototype에 함수를 추가함으로써 여러 객체를 생성하였을 때 해당 함수를 사용할 수 있다. 예를 들어 Person이라는 object 안에 mitt, kim이 있는 경우, mitt.su..