본문 바로가기

[google] the smallest range from k lists http://www.careercup.com/question?id=16759664 You have k lists of sorted integers. Find the smallest range that includes at least one number from each of the k lists. For example, List 1: [4, 10, 15, 24, 26] List 2: [0, 9, 12, 20] List 3: [5, 18, 22, 30] The smallest range here would be [20, 24] as it contains 24 from list 1, 20 from list 2, and 22 from list 3. 더보기
[Oj.leetcode] generate-parentheses Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: "((()))", "(()())", "(())()", "()(())", "()()()" /* "well-formed" 의미를 시작전 명확하게 인터뷰어와 논의. 여기서는 열고( 닫는) 한쌍의 괄호쌍 의미 좀 더 정확하게 정의해보면, 닫힌 괄호가 나왔을때, 앞에 매칭되는 열린괄호가 최소한 1개는 존재해야함. n=1 (), n=2 (()), ()() n=3 ()(()), (()()), ((())), (()()), (())(), ()()() n=4 .. 더보기
Programming pearls(생각하는 프로그래밍) 이 책은 내가 봐온 알고리즘/프로그래밍 관련 책중 단연 손 꼽히는 책. 감동이다 진짜. 구성/내용이 너무 알차다. 강력 추천. 칼럼1~15 로 구성 되어 있고 각 칼럼 마다 연습문제와 해답이 존재한다. 칼럼 1 ~ 5 : 준비 칼럼 6 ~ 10 : 성능 칼럼 11 ~ 15 : 프로덕트 진짜 이 책과 cracking the coding interview 만 잘봐도 인터뷰를 위한 기본 내공을 쌓기에는 충분할 것이라 확신. 칼럼 1 프로그램 디자인 for i = [0, n) : 0부터 n-1까지 반복한다는 의미 '[' 는 open, ')' 는 close 문제 : 한정된 메모리를 활용하여 파일을 읽어들여 정렬 후 다시 디스크에 쓰는 함수 작성하여야 함 입력 : 최대 n개의 양의 정수를 포함하는 파일로, 각 숫자.. 더보기