본문 바로가기

Web Developer1904

leetcode 21 - Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 정렬 된 두 개의 링크 된 목록을 병합하고 새 목록으로 반환하십시오. 새 목록은 처음 두 목록의 노드를 서로 연결하여 만들어야합니다. /** * Definition for singly-linked list. * function ListNode(val) { * this.val = val; * this.next = null; * } */ /** * @param {ListNode} l1 * @param {ListNode} l2 * @return {ListNod.. 2019. 2. 22.
leetcode 20 - Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also considered valid. '(', ')', '{', '}', '['및 ']'문자 만 들어있는 문자열을 입력 문자열이 유효한지 판단하십시오. 입력 문자열은 다음 경우에 유효합니다. 개방.. 2019. 2. 22.
leetcode 50 - Pow(x, n) 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); }; 2019. 2. 19.
leetcode 14 - Longest Common Prefix 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.. 2019. 2. 18.
leetcode 13 - 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, 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.. 2019. 2. 18.
leetcode 9 - Palindrome Number 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(""); }; 2019. 2. 18.