Implement pow(x, n), which calculates x raised to the power n (xn). Power n (xn)으로 x를 계산하는 pow (x, n)을 구현합니다. /** * @param {number} x * @param {number} n * @return {number} */ var myPow = function(x, n) { return Math.pow(x, n).toFixed(5); };
Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". 문자열 배열 사이에서 가장 긴 공통 접두사 문자열을 찾는 함수를 작성하십시오. 공통 접두사가없는 경우 빈 문자열 ""을 반환합니다. I used to eval function. If you use a different language, the code below will not work 자바스크립트이 eval 이라는 특수 함수를 사용해서 풀었다. 다른언어로 푼다면 다른 알고리즘을 사용해야 할 것입니다. /** * @param {string[]} str..
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, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which is simply X + II. The number twenty seven is written as XXVII, which is XX + V + II. Roman numerals are usually written largest to smallest from left..
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. 정수가 회문인지 여부를 결정하십시오. 정수는 전방으로 동일한 것을 읽으면 회문입니다. /** * @param {number} x * @return {boolean} */ var isPalindrome = function(x) { return String(x) == String(x).split("").reverse().join(""); };
Given a 32-bit signed integer, reverse digits of an integer. - 주어진 32 비트 부호있는 정수, 정수의 역 자릿수. /** * @param {number} x * @return {number} */ var reverse = function(x) { var max = Math.pow(2, 31) -1, min = -1*(Math.pow(2, 31)); var r = 0, s = '', signed = 1; if(x >= max || x = max || r
Given a string, find the length of the longest substring without repeating characters. 주어진 문자열에서 반복되는 문자없이 가장 긴 부분 문자열의 길이를 찾습니다. /** * @param {string} s * @return {number} */ var lengthOfLongestSubstring = function(s) { var r = '', t = '', st = 0; for(let i = 0 ; i < s.length ; i++){ let index = t.indexOf(s[i]); if(index != -1){ st = st + index + 1; } t = s.substring(st, i+1); if(r.length < t.l..