Leetcode 23: Merge k sorted lists

https://leetcode.com/problems/merge-k-sorted-lists/ Merge k Sorted Lists Total Accepted: 59265 Total Submissions: 278075 Difficulty: Hard Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.   Code 1: import heapq # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None …

Leetcode 269: Alien Dictionary

https://leetcode.com/problems/alien-dictionary/ Alien Dictionary Total Accepted: 1390 Total Submissions: 8315 Difficulty: Hard There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of words from the dictionary, where words are sorted lexicographically by the rules of this new language. Derive the order …

Review: The Google File System

Original paper: http://static.googleusercontent.com/media/research.google.com/en//archive/gfs-sosp2003.pdf Cons and pros on Quora: https://www.quora.com/Reviews-of-Google-File-System Paper discussion: http://pages.cs.wisc.edu/~swift/classes/cs736-fa08/blog/2008/11/the_google_file_system.html A blog discussion: http://kaushiki-gfs.blogspot.com/ A ppt discussion: http://www.slideshare.net/tutchiio/gfs-google-file-system A QA series: http://pages.cs.wisc.edu/~thanhdo/qual-notes/fs/fs4-gfs.txt GFS wiki: http://google-file-system.wikispaces.asu.edu/ 2.3  GFS uses one-master-mutiple-chunkservers mode. Client will query the master about the metadata of files, which reside in the master’s memory hence query is fast. The real data operation takes place at chunkservers. …

Leetcode 146: LRU cache

https://leetcode.com/problems/lru-cache/ LRU Cache Total Accepted: 50542 Total Submissions: 329169 Difficulty: Hard Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) – Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.set(key, value) …

Leetcode 271: Encode and Decode Strings

https://leetcode.com/problems/encode-and-decode-strings/ Encode and Decode Strings Total Accepted: 1272 Total Submissions: 4999 Difficulty: Medium Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings. Machine 1 (sender) has the function: string encode(vector<string> strs) { // …

Leetcode 1: Two sums

https://leetcode.com/problems/two-sum/ Two Sum Total Accepted: 141545 Total Submissions: 770154 Difficulty: Medium Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please …

Leetcode 33: Search in Rotated Sorted Array

https://leetcode.com/problems/search-in-rotated-sorted-array/ Search in Rotated Sorted Array Total Accepted: 72911 Total Submissions: 252621 Difficulty: Hard Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in …

Leetcode 272: Closest Binary Search Tree Value II

https://leetcode.com/problems/closest-binary-search-tree-value-ii/ Closest Binary Search Tree Value II Total Accepted: 1212 Total Submissions: 4499 Difficulty: Hard Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target. Note: Given target value is a floating point. You may assume k is always valid, that is: k …

Leetcode 10: Regular Expression Matching

https://leetcode.com/problems/regular-expression-matching/ Regular Expression Matching Total Accepted: 57005 Total Submissions: 274700 Difficulty: Hard Implement regular expression matching with support for '.' and '*'. ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). The function prototype should be: bool isMatch(const char *s, …