리트코드/easy (22) 썸네일형 리스트형 [리트코드] 13. Roman to Integer - js 1. 문제 https://leetcode.com/problems/roman-to-integer/ Roman to Integer - LeetCode Can you solve this real interview question? Roman to Integer - Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just tw leetcode.com 2. 코드 /** * @param {string} s * @return {number} .. [리트코드] 2784. Check if Array is Good - js 1. 문제 https://leetcode.com/problems/check-if-array-is-good/ 2. 코드 /** * @param {number[]} nums * @return {boolean} */ var isGood = function(nums) { let sortedNums = nums.sort((a,b) => a-b); if(sortedNums[sortedNums.length-1] !== sortedNums[sortedNums.length-2]) return false; for(let i=0;i [리트코드] 35. Search Insert Position - js (이진탐색) 1. 문제 https://leetcode.com/problems/search-insert-position/ Search Insert Position - LeetCode Can you solve this real interview question? Search Insert Position - Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must w leetcode.com 2. 코드 /** * @param {number[]} nums .. [리트코드] 283. Move Zeroes - js (투포인터) 1. 문제 https://leetcode.com/problems/move-zeroes/description/ Move Zeroes - LeetCode Can you solve this real interview question? Move Zeroes - Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a copy of the array. E leetcode.com 2. 코드 처음 작성한 코드) 오답 nums = [0,0,1] 일 경우 답이 [0,1.. [리트코드] 704. Binary Search - js 1. 문제 https://leetcode.com/problems/binary-search/ Binary Search - LeetCode Can you solve this real interview question? Binary Search - Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1. leetcode.com 2. 코드 /** * @param {number[]} nums * @param {number}.. [리트코드] 169. Majority Element - js (해시) 1. 문제 https://leetcode.com/problems/majority-element/ 2. 코드 /** * @param {number[]} nums * @return {number} */ var majorityElement = function(nums) { let map = new Map(); for(let n of nums){ map.set(n, (map.get(n) || 0) + 1); } for(let [k,v] of map){ if(v >= nums.length / 2) return k; } }; [리트코드] 1. Two Sum - js 1. 문제 https://leetcode.com/problems/two-sum/ Two Sum - LeetCode Can you solve this real interview question? Two Sum - Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not leetcode.com 2. 코드 /** * @param {number[]} nums * @param {number} target * @re.. [리트코드] 345. Reverse Vowels of a String - js 1. 문제 https://leetcode.com/problems/reverse-vowels-of-a-string/ Reverse Vowels of a String - LeetCode Can you solve this real interview question? 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 onc leetcode.com 2. 코드 이 문제는 투 포인터를 사용해야하는 .. 이전 1 2 3 다음