Programming/CS
-
TIL_setTimeout()Programming/CS 2019. 11. 29. 01:52
functoion A가 있다. 그리고 그 안에, functoin B와 function C가 있다. function A를 호출하였을 때, function B를 실행시킨뒤 3초 뒤, function C를 실행시키려고 한다. 어떻게 구현할 수 있을까? 일단, B와 C를 실행하기 전에 3초 동안의 지연을 주어야하기 때문에 특정시간 이후에 동작하도록 하는 자바스크립트 내장 함수인 setTimeout()을 떠올릴 수 있다. setTimeout('실행할 함수' , 지연시간); setTimeout() 은 이러한 파라미터를 가지고 첫번째 인자의 함수 (callback fn) 가, 두번째 인자만큼의 일정 시간이 지나면 실행(delay) 될 수 있도록한다. 그런데, 이는 단순히 '몇초 지연 되었다가 실행' 의 의미를 갖고 ..
-
leetcode_Two City SchedulingProgramming/CS 2019. 11. 16. 02:18
오늘은 leetcode의 Two City Scheduling을 풀어보았다. There are 2N people a company is planning to interview. The cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th person to city B is costs[i][1]. Return the minimum cost to fly every person to a city such that exactly N people arrive in each city input : [[10,20],[30,200],[400,50],[30,20]] outpupt : 110 인터뷰를 위해 회사로 가야하..