본문 바로가기

반응형

리트코드/easy

(22)
[리트코드] 70. Climbing Stairs - js (메모이제이션) 1. 문제 https://leetcode.com/problems/climbing-stairs/description/ Climbing Stairs - LeetCode Can you solve this real interview question? Climbing Stairs - You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Input: n = 2 Outpu leetcode.com 2. 코드 처음 짠 코드) 타임 아웃 /** * @param {numb..
[리트코드] 14. Longest Common Prefix - js 1. 문제 https://leetcode.com/problems/longest-common-prefix/ Longest Common Prefix - LeetCode Can you solve this real interview question? 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 "". Example 1: Input: strs = ["flower","flow" leetcode.com 2. 코드 /** * @param {string[]} strs * @r..
[리트코드] 2806. Account Balance After Rounded Purchase - js 1. 문제 https://leetcode.com/problems/account-balance-after-rounded-purchase/ Account Balance After Rounded Purchase - LeetCode Can you solve this real interview question? Account Balance After Rounded Purchase - Initially, you have a bank account balance of 100 dollars. You are given an integer purchaseAmount representing the amount you will spend on a purchase in dollars. At the leetcode.com 2. ..
[리트코드] 205. Isomorphic Strings - js 1. 문제 https://leetcode.com/problems/isomorphic-strings/ Isomorphic Strings - LeetCode Can you solve this real interview question? Isomorphic Strings - Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replace leetcode.com 2. 코드 이 문제는 설명을 이해하는데 조금 오래 걸렸다. Isomorphi..
[리트코드] 121. Best Time to Buy and Sell Stock - js 1. 문제 https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/ Best Time to Buy and Sell Stock - LeetCode Can you solve this real interview question? 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 choosin leetcode.com 2. 코..
[리트코드] 20. Valid Parentheses - js 1. 문제 https://leetcode.com/problems/valid-parentheses/ 2. 코드 /** * @param {string} s * @return {boolean} */ var isValid = function(s) { if(s.length % 2) return false; let stack = []; for(let i=0;i
[리트코드] 69. Sqrt(x) - js 1. 문제 https://leetcode.com/problems/sqrtx/ 2. 코드 /** * @param {number} x * @return {number} */ var mySqrt = function(x) { return Math.floor(Math.sqrt(x)); };
[리트코드] 509. Fibonacci Number - js 1. 문제 https://leetcode.com/problems/fibonacci-number/ Fibonacci Number - LeetCode Can you solve this real interview question? Fibonacci Number - The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is, F(0) = 0 leetcode.com 2. 코드 /** * @param {number} n * @return {numbe..

반응형