본문 바로가기

반응형

리트코드

(55)
[리트코드] 994. Rotting Oranges - js (BFS) 1. 문제 https://leetcode.com/problems/rotting-oranges/description/ Rotting Oranges - LeetCode Can you solve this real interview question? Rotting Oranges - You are given an m x n grid where each cell can have one of three values: * 0 representing an empty cell, * 1 representing a fresh orange, or * 2 representing a rotten orange. Every minute, any leetcode.com 2. 코드 처음 작성한 코드) 예상했지만..타임아웃 /** * @p..
[리트코드] 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. 코..
[리트코드] 11. Container With Most Water - js (투포인터) 1. 문제 https://leetcode.com/problems/container-with-most-water/ Container With Most Water - LeetCode Can you solve this real interview question? Container With Most Water - You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that toget leetcode.com 2. 코드 /** * @param {number[]..
[리트코드] 72. Edit Distance - js (DP) 1. 문제 https://leetcode.com/problems/edit-distance/ Edit Distance - LeetCode Can you solve this real interview question? Edit Distance - Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word: * Insert a character * D leetcode.com 2. 코드 다양한 문제를 봤을 때, 두 개의 문자열의 각 자리를 비교하여 최소값을 리턴한다, ..
[리트코드] 1143. Longest Common Subsequence - js (DP) 1. 문제 https://leetcode.com/problems/longest-common-subsequence/ Longest Common Subsequence - LeetCode Can you solve this real interview question? Longest Common Subsequence - Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. A subsequence of a string is a new string genera leetcode.com 2. 코드 이 문제는 DP(누적합)를 이용하여 ..
[리트코드] 200. Number of Islands - js (DFS) 1. 문제 https://leetcode.com/problems/number-of-islands/description/ Number of Islands - LeetCode Can you solve this real interview question? Number of Islands - Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent l 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
[리트코드] 394. Decode String - js 1. 문제 https://leetcode.com/problems/decode-string/ Decode String - LeetCode Can you solve this real interview question? Decode String - Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is g leetcode.com 2. 코드 /** * @param {string} s * @return {string} */ ..

반응형