## leetcode Find Median from Data Stream

### leetcode Find Median from Data Stream

Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.

Examples:
[2,3,4] , the median is 3

[2,3], the median is (2 + 3) / 2 = 2.5

Design a data structure that supports the following two operations:

• void addNum(int num) – Add a integer number from the data stream to the data structure.
• double findMedian() – Return the median of all elements so far.

For example:

• findMedian() -> 1.5
• findMedian() -> 2

## leetcode Nim Game

### leetcode Nim Game

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.

Both of you are very clever and have optimal strategies for the game. Write a function to determine whether you can win the game given the number of stones in the heap.

For example, if there are 4 stones in the heap, then you will never win the game: no matter 1, 2, or 3 stones you remove, the last stone will always be removed by your friend.

• push
• pop
• 堆的创建及其他应用

## leetcode Graph 图论

• 133 Clone Graph
• 207 Course Schedule
• 210 Course Schedule II

## leetcode 链表

• 依照leetcode定义 自己写的链表创建/打印方法，便于测试
• 19 Remove Nth Node From End of List
• 21 Merge Two Sorted Lists
• 24 Swap Nodes in Pairs
• 25 Reverse Nodes in k-Group
• 61 Rotate List
• 138 Copy List with Random Pointer
• 142 Linked List Cycle II
• 143 Reorder List
• 147 Insertion Sort List
• 148 Sort List
• 160 Intersection of Two Linked Lists
• 203 Remove Linked List Elements
• 237 Delete Node in a Linked List

update:2015-7-14

• add a 203 solution code:
• using recursion and reference to delete linklist node which value equals x
• 单项链表递归删除，使用引用

## leetcode hashtable

• hashtable简洁即实现
• Longest Substring Without Repeating Characters
• 160 Intersection of Two Linked Lists
• 202 Happy Number
• 242 Valid Anagram

## leetcode 动态规划（DP）

• 53 Maximum Subarray
• 62 Unique Paths
• 63 Unique Paths II
• 64 Minimum Path Sum
• 70 Climbing Stairs
• 72 Edit Distance
• 91 Decode Ways
• 97 Interleaving String
• 115 Distinct Subsequences
• 139 Word Break
• 140 Word Break II
• 152 Maximum Product Subarray
• 174 Dungeon Game
• 198 House Robber
• 213 House Robber II
• 221 Maximal Square

## leetcode 回文串

• 5 Longest Palindromic Substring
• Palindrome Number
• 125 Valid Palindrome
• 131 Palindrome Partitioning
• 132 Palindrome Partitioning II
• 214 Shortest Palindrome
• 336 Palindrome Pairs

## leetcode 位运算

• 136 Single Number
• 137 Single Number II
• 190 Reverse Bits
• 191 Number of 1 Bits
• 201 Bitwise AND of Numbers Range
• 260 Single Number III
• 268 Missing Number