본문 바로가기

반응형

리트코드/midium

(32)
[리트코드] 215. Kth Largest Element in an Array 1. 문제 https://leetcode.com/problems/kth-largest-element-in-an-array/ 2. 코드 /** * @param {number[]} nums * @param {number} k * @return {number} */ var findKthLargest = function(nums, k) { let sortedNums = nums.sort((a,b) => b-a); return sortedNums[k-1]; };
[리트코드] 49. Group Anagrams - js 1. 문제 https://leetcode.com/problems/group-anagrams/description/ Group Anagrams - LeetCode Can you solve this real interview question? Group Anagrams - Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase leetcode.com 2. 코드 같은 알파벳 조합으로 이루어진 단어들을 배열로 묶어 리턴하..
[리트코드] 39. Combination Sum - js 1. 문제 https://leetcode.com/problems/combination-sum/ Combination Sum - LeetCode Can you solve this real interview question? Combination Sum - Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the comb leetcode.com 2. 코드 /** * @param {number[]} candidates * @para..
[리트코드] 230. Kth Smallest Element in a BST - js 1. 문제 https://leetcode.com/problems/kth-smallest-element-in-a-bst/submissions/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 2. 코드 /** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.va..
[리트코드] 48. Rotate Image - js 1. 문제 https://leetcode.com/problems/rotate-image/description/ Rotate Image - LeetCode Can you solve this real interview question? Rotate Image - You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place [https://en.wikipedia.org/wiki/In-place_algorithm], which m leetcode.com 2. 코드 이 문제는 다른 문제들과 달리 새로운 matrix를 선언하여 re..
[리트코드] 22. Generate Parentheses - js 1. 문제 https://leetcode.com/problems/generate-parentheses/description/ Generate Parentheses - LeetCode Can you solve this real interview question? Generate Parentheses - Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1: Input: n = 3 Output: ["((()))","(()())","(())()","()(())","()()()"] Exa leetcode.com 2. 코드 이 문제는 백트래킹을 활용하는 문제다. 백..
[리트코드] 78. Subsets - js 1. 문제 https://leetcode.com/problems/subsets/description/ Subsets - LeetCode Can you solve this real interview question? Subsets - Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example 1: Input: n leetcode.com 2. 코드 /** * @param {number[]} nums * @return {number[][..
[리트코드] 46. Permutations - js 1. 문제 https://leetcode.com/problems/permutations/ Permutations - LeetCode Can you solve this real interview question? Permutations - Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1], leetcode.com 2. 코드 /** * @param {number[]} nums * @return {number[][]}..

반응형