전체 글
-
leetCode - Letter Combinations of a Phone Number(backtracking)프로그래밍/algorithm 2021. 7. 22. 09:26
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. Example 1: Input: digits = "23" Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"] Example 2: Input: digits = ""..
-
leetCode - 3Sum Closest프로그래밍/algorithm 2021. 7. 21. 13:48
문제 Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example 1: Input: nums = [-1,2,1,-4], target = 1 Output: 2 Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). Constraints: 3
-
Blocking vs Non-Blocking프로그래밍/Node 2021. 7. 20. 13:31
Node를 공부하면서, 중요한 개념인 이벤트 루프를 공부 해 보고자 한다. 내가 선택한 방법은 무식하지만 그냥 node doc문서를 다 해석하는 것. Node.js에서 blocking 과 non-blocking의 차이점을 살펴보자. 이번 개요에서 이벤트 루프 및 libuv를 참조하지만 해당 주제에 대한 사전 지식이 필요하지는 않다. 이 글을 읽는 독자에게는 Javascript언어 및 Node.js 콜백 패턴에 대한 기본적인 이해가 있다고 가정한다. "I/O"는 주로 libuv가 지원하는 시스템의 디스크 및 네트워크와의 상호 작용을 나타낸다. Blocking Blocking은 Node.js 프로세스에서 추가적인 Javascript 실행이 non-Javascript 작업이 완료될 떄까지 기다려야 하는 경우이..
-
call/apply와 데코레이터, 포워딩프로그래밍/Js 2021. 7. 20. 11:56
https://ko.javascript.info/call-apply-decorators 내용을 요약한 것이다 코드 변경없이 캐싱 기능 추가하기 function slow(x) { // CPU 집약적인 작업이 여기에 올 수 있습니다. alert(`slow(${x})을/를 호출함`); return x; } function cachingDecorator(func) { let cache = new Map(); return function(x) { if (cache.has(x)) { // cache에 해당 키가 있으면 return cache.get(x); // 대응하는 값을 cache에서 읽어옵니다. } let result = func(x); // 그렇지 않은 경우엔 func를 호출하고, cache.set(x, r..
-
leetCode - 3sum프로그래밍/algorithm 2021. 7. 20. 11:41
문제 Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets. Example 1: Input: nums = [-1,0,1,2,-1,-4] Output: [[-1,-1,2],[-1,0,1]] Example 2: Input: nums = [] Output: [] Example 3: Input: nums = [0] Output: [] Constraints: 0
-
leetCode - Integer to Roman프로그래밍/algorithm 2021. 7. 20. 08:55
문제 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, 2 is written as II in Roman numeral, just two one's added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II. Roman numerals are usually written largest to smallest from left to right. Howe..
-
leetCode - Container With Most Water프로그래밍/algorithm 2021. 7. 20. 07:21
문제 Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water. Notice that you may not slant the container. Example 1: Input: height = [1,8,6,2,5,..