프로그래밍
-
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,..
-
leetCode - Regular Expression Matching프로그래밍/algorithm 2021. 7. 19. 10:58
문제 Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). Example 1: Input: s = "aa", p = "a" Output: false Explanation: "a" does not match the entire string "aa". Example 2: Input: s ..
-
leetCode - Reverse Integer프로그래밍/algorithm 2021. 7. 19. 08:31
문제 Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned). Example 1: Input: x = 123 Output: 321 Example 2: Input: x = -123 Output: -321 Example 3: Input: x = 120 Output: 21 Example 4: In..
-
leetCode - ZigZag Conversion프로그래밍/algorithm 2021. 7. 19. 07:44
문제 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conversion given a number of rows: string convert(string s, int numRows); Example 1: Input: s = "..