1. LeetCode 1
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,15], target = 9 Output: [0,1] Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
Example 2:
Input: nums = [3,2,4], target = 6 Output: [1,2]
Example 3:
Input: nums = [3,3], target = 6 Output: [0,1]
Constraints:
 2 <= nums.length <= 104
 109 <= nums[i] <= 109
 109 <= target <= 109
 Only one valid answer exists.
Followup: Can you come up with an algorithm that is less than O(n2) time complexity?
2. 消消乐
给你一个字符串代表一行消糖果游戏，该如何消掉所有>=3个以上上的糖果？最后返还一个字符代表消完后的结果。 ex:"abbbbccca"=>"aa"。先消ccc>bbbb,剩下aa消不掉
3. Word Ladder
是一道成语接龙的变形题，给定一个字 lead,变成gold 最少需要多少步？
参数,起始字，结尾字，字典ex:{"load""goad"} 例子：lead> load> goad> gold
参数,起始字，结尾字，字典ex:{"load""goad"} 例子：lead> load> goad> gold
4. 设计meet up
设计一个类似meetup的软件
5. 实现文件内同合并
"Implement the function:
def merge_files(file1, file2, output_file)
Where file 1 and file 2 are filepaths and the function will read the two files and merge the contents and output into output file
File 1:
id n B A
ID12D1D2
ID22D1D2
ID32D1D2
ID400000002D1D2
File 2:
id n Ｃ D
ID12D3D4
ID32D3D4
ID42D3D4
ID52D3D4
ID62D3D4
..X 1000000
ID400000002D1D2
Output File:
ID14D1D2D3D4
ID24D1D2N.AN.A
ID34D1D2D3D4
ID44D1D2D3D4
ID54N.AN.AD3D4
ID64N.AN.AD3D4
Follow up：如果档案很大怎么处理"
def merge_files(file1, file2, output_file)
Where file 1 and file 2 are filepaths and the function will read the two files and merge the contents and output into output file
File 1:
id n B A
ID12D1D2
ID22D1D2
ID32D1D2
ID400000002D1D2
File 2:
id n Ｃ D
ID12D3D4
ID32D3D4
ID42D3D4
ID52D3D4
ID62D3D4
..X 1000000
ID400000002D1D2
Output File:
ID14D1D2D3D4
ID24D1D2N.AN.A
ID34D1D2D3D4
ID44D1D2D3D4
ID54N.AN.AD3D4
ID64N.AN.AD3D4
Follow up：如果档案很大怎么处理"
6. LeetCode 252
Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings.
Example 1:
Input: intervals = [[0,30],[5,10],[15,20]] Output: false
Example 2:
Input: intervals = [[7,10],[2,4]] Output: true
Constraints:
 0 <= intervals.length <= 104
 intervals[i].length == 2
 0 <= starti < endi <= 106
7. Job schedule
# Running a bunch of jobs on some schedule
#［(1,3),(2,4),(5,7)]
# What are the periods of time when no jobs are running
#［(4,5)]
# What is the maximum number of jobs that run at the same time (2)
# If each job needs its own machine, how many machines do we need
#1 2 3 4 5 6 7




#［(1,3),(2,4),(5,7)]
# What are the periods of time when no jobs are running
#［(4,5)]
# What is the maximum number of jobs that run at the same time (2)
# If each job needs its own machine, how many machines do we need
#1 2 3 4 5 6 7




8. LeetCode 394
Given an encoded string, return its decoded string.
The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer.
You may assume that the input string is always valid; there are no extra white spaces, square brackets are wellformed, etc. Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, k. For example, there will not be input like 3a or 2[4].
The test cases are generated so that the length of the output will never exceed 105.
Example 1:
Input: s = "3[a]2[bc]"
Output: "aaabcbc"
Example 2:
Input: s = "3[a2[c]]"
Output: "accaccacc"
Example 3:
Input: s = "2[abc]3[cd]ef"
Output: "abcabccdcdcdef"
Constraints:
1 <= s.length <= 30
s consists of lowercase English letters, digits, and square brackets '[]'.
s is guaranteed to be a valid input.
All the integers in s are in the range [1, 300].
The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer.
You may assume that the input string is always valid; there are no extra white spaces, square brackets are wellformed, etc. Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, k. For example, there will not be input like 3a or 2[4].
The test cases are generated so that the length of the output will never exceed 105.
Example 1:
Input: s = "3[a]2[bc]"
Output: "aaabcbc"
Example 2:
Input: s = "3[a2[c]]"
Output: "accaccacc"
Example 3:
Input: s = "2[abc]3[cd]ef"
Output: "abcabccdcdcdef"
Constraints:
1 <= s.length <= 30
s consists of lowercase English letters, digits, and square brackets '[]'.
s is guaranteed to be a valid input.
All the integers in s are in the range [1, 300].
9. LeetCode 253
Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required.
Example 1:
Input: intervals = [[0,30],[5,10],[15,20]] Output: 2
Example 2:
Input: intervals = [[7,10],[2,4]] Output: 1
Constraints:
 1 <= intervals.length <= 104
 0 <= starti < endi <= 106
10. LeetCode 117
Given a binary tree
struct Node { int val; Node *left; Node *right; Node *next; }
Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.
Initially, all next pointers are set to NULL.
Example 1:
Input: root = [1,2,3,4,5,null,7] Output: [1,#,2,3,#,4,5,7,#] Explanation: Given the above binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level.
Example 2:
Input: root = [] Output: []
Constraints:
 The number of nodes in the tree is in the range [0, 6000].
 100 <= Node.val <= 100
Followup:
 You may only use constant extra space.
 The recursive approach is fine. You may assume implicit stack space does not count as extra space for this problem.
11. LeetCode 3
Given a string s, find the length of the longest substring without repeating characters.
Example 1:
Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3.
Example 2:
Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1.
Example 3:
Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3. Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.
Constraints:
 0 <= s.length <= 5 * 104
 s consists of English letters, digits, symbols and spaces.
12. 股票数据结构
设计一个数据结构，不断加入股票名字和价格，要求：
1.给股票名字，求最大值
2.给股票名字，求最小值
3.给股票名字，求最近的五个股票价格（如果不足5个显示当前已有的数量的价格）
1.给股票名字，求最大值
2.给股票名字，求最小值
3.给股票名字，求最近的五个股票价格（如果不足5个显示当前已有的数量的价格）
13. LeetCode 116
You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:
struct Node { int val; Node *left; Node *right; Node *next; }
Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.
Initially, all next pointers are set to NULL.
Example 1:
Input: root = [1,2,3,4,5,6,7] Output: [1,#,2,3,#,4,5,6,7,#] Explanation: Given the above perfect binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level.
Example 2:
Input: root = [] Output: []
Constraints:
 The number of nodes in the tree is in the range [0, 212  1].
 1000 <= Node.val <= 1000
Followup:
 You may only use constant extra space.
 The recursive approach is fine. You may assume implicit stack space does not count as extra space for this problem.
14. LeetCode 79
Given an m x n grid of characters board and a string word, return true if word exists in the grid.
The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.
Example 1:
Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED" Output: true
Example 2:
Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "SEE" Output: true
Example 3:
Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCB" Output: false
Constraints:
 m == board.length
 n = board[i].length
 1 <= m, n <= 6
 1 <= word.length <= 15
 board and word consists of only lowercase and uppercase English letters.
Follow up: Could you use search pruning to make your solution faster with a larger board?
15. LeetCode 53
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
A subarray is a contiguous part of an array.
Example 1:
Input: nums = [2,1,3,4,1,2,1,5,4] Output: 6 Explanation: [4,1,2,1] has the largest sum = 6.
Example 2:
Input: nums = [1] Output: 1
Example 3:
Input: nums = [5,4,1,7,8] Output: 23
Constraints:
 1 <= nums.length <= 105
 104 <= nums[i] <= 104
Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.
16. LeetCode 1
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,15], target = 9 Output: [0,1] Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
Example 2:
Input: nums = [3,2,4], target = 6 Output: [1,2]
Example 3:
Input: nums = [3,3], target = 6 Output: [0,1]
Constraints:
 2 <= nums.length <= 104
 109 <= nums[i] <= 109
 109 <= target <= 109
 Only one valid answer exists.
Followup: Can you come up with an algorithm that is less than O(n2) time complexity?
17. LeetCode 15
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 <= nums.length <= 3000
 105 <= nums[i] <= 105
18. LeetCode 146
Implement the LRUCache class:
 LRUCache(int capacity) Initialize the LRU cache with positive size capacity.
 int get(int key) Return the value of the key if the key exists, otherwise return 1.
 void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the keyvalue pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
The functions get and put must each run in O(1) average time complexity.
Example 1:
Input ["LRUCache", "put", "put", "get", "put", "get", "put", "get", "get", "get"] [[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]] Output [null, null, null, 1, null, 1, null, 1, 3, 4] Explanation LRUCache lRUCache = new LRUCache(2); lRUCache.put(1, 1); // cache is {1=1} lRUCache.put(2, 2); // cache is {1=1, 2=2} lRUCache.get(1); // return 1 lRUCache.put(3, 3); // LRU key was 2, evicts key 2, cache is {1=1, 3=3} lRUCache.get(2); // returns 1 (not found) lRUCache.put(4, 4); // LRU key was 1, evicts key 1, cache is {4=4, 3=3} lRUCache.get(1); // return 1 (not found) lRUCache.get(3); // return 3 lRUCache.get(4); // return 4
Constraints:
 1 <= capacity <= 3000
 0 <= key <= 104
 0 <= value <= 105
 At most 2 * 105 calls will be made to get and put.
19. linked list level order
Print linked list(with next pointer to another linkedlist) level by level.
1>2>3>9
 
4>5>6 10>11

7>8
input:listnode(1)
output: print result [[1,2,3,9],[4,5,6,10,11],[7,8]]
1>2>3>9
 
4>5>6 10>11

7>8
input:listnode(1)
output: print result [[1,2,3,9],[4,5,6,10,11],[7,8]]
20. LeetCode 212
Given an m x n board of characters and a list of strings words, return all words on the board.
Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.
Example 1:
Input: board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]], words = ["oath","pea","eat","rain"] Output: ["eat","oath"]
Example 2:
Input: board = [["a","b"],["c","d"]], words = ["abcb"] Output: []
Constraints:
 m == board.length
 n == board[i].length
 1 <= m, n <= 12
 board[i][j] is a lowercase English letter.
 1 <= words.length <= 3 * 104
 1 <= words[i].length <= 10
 words[i] consists of lowercase English letters.
 All the strings of words are unique.
21. LeetCode 4
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
The overall run time complexity should be O(log (m+n)).
Example 1:
Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and median is 2.
Example 2:
Input: nums1 = [1,2], nums2 = [3,4] Output: 2.50000 Explanation: merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.
Constraints:
 nums1.length == m
 nums2.length == n
 0 <= m <= 1000
 0 <= n <= 1000
 1 <= m + n <= 2000
 106 <= nums1[i], nums2[i] <= 106
22. LeetCode 3
Given a string s, find the length of the longest substring without repeating characters.
Example 1:
Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3.
Example 2:
Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1.
Example 3:
Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3. Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.
Constraints:
 0 <= s.length <= 5 * 104
 s consists of English letters, digits, symbols and spaces.
23. Design an access management system
Design an access management system
24. LeetCode 46
Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.
Example 1:
Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
Example 2:
Input: nums = [0,1] Output: [[0,1],[1,0]]
Example 3:
Input: nums = [1] Output: [[1]]
Constraints:
 1 <= nums.length <= 6
 10 <= nums[i] <= 10
 All the integers of nums are unique.
25. LeetCode 1396
An underground railway system is keeping track of customer travel times between different stations. They are using this data to calculate the average time it takes to travel from one station to another.
Implement the UndergroundSystem class:
 void checkIn(int id, string stationName, int t)
 A customer with a card ID equal to id, checks in at the station stationName at time t.
 A customer can only be checked into one place at a time.
 void checkOut(int id, string stationName, int t)
 A customer with a card ID equal to id, checks out from the station stationName at time t.
 double getAverageTime(string startStation, string endStation)
 Returns the average time it takes to travel from startStation to endStation.
 The average time is computed from all the previous traveling times from startStation to endStation that happened directly, meaning a check in at startStation followed by a check out from endStation.
 The time it takes to travel from startStation to endStation may be different from the time it takes to travel from endStation to startStation.
 There will be at least one customer that has traveled from startStation to endStation before getAverageTime is called.
You may assume all calls to the checkIn and checkOut methods are consistent. If a customer checks in at time t1 then checks out at time t2, then t1 < t2. All events happen in chronological order.
Example 1:
Input ["UndergroundSystem","checkIn","checkIn","checkIn","checkOut","checkOut","checkOut","getAverageTime","getAverageTime","checkIn","getAverageTime","checkOut","getAverageTime"] [[],[45,"Leyton",3],[32,"Paradise",8],[27,"Leyton",10],[45,"Waterloo",15],[27,"Waterloo",20],[32,"Cambridge",22],["Paradise","Cambridge"],["Leyton","Waterloo"],[10,"Leyton",24],["Leyton","Waterloo"],[10,"Waterloo",38],["Leyton","Waterloo"]] Output [null,null,null,null,null,null,null,14.00000,11.00000,null,11.00000,null,12.00000] Explanation UndergroundSystem undergroundSystem = new UndergroundSystem(); undergroundSystem.checkIn(45, "Leyton", 3); undergroundSystem.checkIn(32, "Paradise", 8); undergroundSystem.checkIn(27, "Leyton", 10); undergroundSystem.checkOut(45, "Waterloo", 15); // Customer 45 "Leyton" > "Waterloo" in 153 = 12 undergroundSystem.checkOut(27, "Waterloo", 20); // Customer 27 "Leyton" > "Waterloo" in 2010 = 10 undergroundSystem.checkOut(32, "Cambridge", 22); // Customer 32 "Paradise" > "Cambridge" in 228 = 14 undergroundSystem.getAverageTime("Paradise", "Cambridge"); // return 14.00000. One trip "Paradise" > "Cambridge", (14) / 1 = 14 undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 11.00000. Two trips "Leyton" > "Waterloo", (10 + 12) / 2 = 11 undergroundSystem.checkIn(10, "Leyton", 24); undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 11.00000 undergroundSystem.checkOut(10, "Waterloo", 38); // Customer 10 "Leyton" > "Waterloo" in 3824 = 14 undergroundSystem.getAverageTime("Leyton", "Waterloo"); // return 12.00000. Three trips "Leyton" > "Waterloo", (10 + 12 + 14) / 3 = 12
Example 2:
Input ["UndergroundSystem","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime"] [[],[10,"Leyton",3],[10,"Paradise",8],["Leyton","Paradise"],[5,"Leyton",10],[5,"Paradise",16],["Leyton","Paradise"],[2,"Leyton",21],[2,"Paradise",30],["Leyton","Paradise"]] Output [null,null,null,5.00000,null,null,5.50000,null,null,6.66667] Explanation UndergroundSystem undergroundSystem = new UndergroundSystem(); undergroundSystem.checkIn(10, "Leyton", 3); undergroundSystem.checkOut(10, "Paradise", 8); // Customer 10 "Leyton" > "Paradise" in 83 = 5 undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.00000, (5) / 1 = 5 undergroundSystem.checkIn(5, "Leyton", 10); undergroundSystem.checkOut(5, "Paradise", 16); // Customer 5 "Leyton" > "Paradise" in 1610 = 6 undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 5.50000, (5 + 6) / 2 = 5.5 undergroundSystem.checkIn(2, "Leyton", 21); undergroundSystem.checkOut(2, "Paradise", 30); // Customer 2 "Leyton" > "Paradise" in 3021 = 9 undergroundSystem.getAverageTime("Leyton", "Paradise"); // return 6.66667, (5 + 6 + 9) / 3 = 6.66667
Constraints:
 1 <= id, t <= 106
 1 <= stationName.length, startStation.length, endStation.length <= 10
 All strings consist of uppercase and lowercase English letters and digits.
 There will be at most 2 * 104 calls in total to checkIn, checkOut, and getAverageTime.
 Answers within 105 of the actual value will be accepted.
26. LeetCode 121
You are given an array prices where prices[i] is the price of a given stock on the ith day.
You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.
Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.
Example 1:
Input: prices = [7,1,5,3,6,4] Output: 5 Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 61 = 5. Note that buying on day 2 and selling on day 1 is not allowed because you must buy before you sell.
Example 2:
Input: prices = [7,6,4,3,1] Output: 0 Explanation: In this case, no transactions are done and the max profit = 0.
Constraints:
 1 <= prices.length <= 105
 0 <= prices[i] <= 104
27. LeetCode 242
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
Example 1:
Input: s = "anagram", t = "nagaram" Output: true
Example 2:
Input: s = "rat", t = "car" Output: false
Constraints:
 1 <= s.length, t.length <= 5 * 104
 s and t consist of lowercase English letters.
Follow up: What if the inputs contain Unicode characters? How would you adapt your solution to such a case?
28. LeetCode 1583
You are given a list of preferences for n friends, where n is always even.
For each person i, preferences[i] contains a list of friends sorted in the order of preference. In other words, a friend earlier in the list is more preferred than a friend later in the list. Friends in each list are denoted by integers from 0 to n1.
All the friends are divided into pairs. The pairings are given in a list pairs, where pairs[i] = [xi, yi] denotes xi is paired with yi and yi is paired with xi.
However, this pairing may cause some of the friends to be unhappy. A friend x is unhappy if x is paired with y and there exists a friend u who is paired with v but:
 x prefers u over y, and
 u prefers x over v.
Return the number of unhappy friends.
Example 1:
Input: n = 4, preferences = [[1, 2, 3], [3, 2, 0], [3, 1, 0], [1, 2, 0]], pairs = [[0, 1], [2, 3]] Output: 2 Explanation: Friend 1 is unhappy because:  1 is paired with 0 but prefers 3 over 0, and  3 prefers 1 over 2. Friend 3 is unhappy because:  3 is paired with 2 but prefers 1 over 2, and  1 prefers 3 over 0. Friends 0 and 2 are happy.
Example 2:
Input: n = 2, preferences = [[1], [0]], pairs = [[1, 0]] Output: 0 Explanation: Both friends 0 and 1 are happy.
Example 3:
Input: n = 4, preferences = [[1, 3, 2], [2, 3, 0], [1, 3, 0], [0, 2, 1]], pairs = [[1, 3], [0, 2]] Output: 4
Constraints:
 2 <= n <= 500
 n is even.
 preferences.length == n
 preferences[i].length == n  1
 0 <= preferences[i][j] <= n  1
 preferences[i] does not contain i.
 All values in preferences[i] are unique.
 pairs.length == n/2
 pairs[i].length == 2
 xi != yi
 0 <= xi, yi <= n  1
 Each person is contained in exactly one pair.
29. LeetCode 1962
You are given a 0indexed integer array piles, where piles[i] represents the number of stones in the ith pile, and an integer k. You should apply the following operation exactly k times:
 Choose any piles[i] and remove floor(piles[i] / 2) stones from it.
Notice that you can apply the operation on the same pile more than once.
Return the minimum possible total number of stones remaining after applying the k operations.
floor(x) is the greatest integer that is smaller than or equal to x (i.e., rounds x down).
Example 1:
Input: piles = [5,4,9], k = 2 Output: 12 Explanation: Steps of a possible scenario are:  Apply the operation on pile 2. The resulting piles are [5,4,5].  Apply the operation on pile 0. The resulting piles are [3,4,5]. The total number of stones in [3,4,5] is 12.
Example 2:
Input: piles = [4,3,6,7], k = 3 Output: 12 Explanation: Steps of a possible scenario are:  Apply the operation on pile 2. The resulting piles are [4,3,3,7].  Apply the operation on pile 3. The resulting piles are [4,3,3,4].  Apply the operation on pile 0. The resulting piles are [2,3,3,4]. The total number of stones in [2,3,3,4] is 12.
Constraints:
 1 <= piles.length <= 105
 1 <= piles[i] <= 104
 1 <= k <= 105
30. Deep copy a linked list
给一个linked list with random field,make deep copy
31. Collatzconjecture算术
输入一个数，如果是偶数，那么除2；如果是奇数那么乘3+1；最后当数字变为1的时候，返回操作步数
举例：16>8>4>2>1返回4步
3>10>5>16>8>4>2>1返回7步
举例：16>8>4>2>1返回4步
3>10>5>16>8>4>2>1返回7步
32. LeetCode 1209
You are given a string s and an integer k, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them, causing the left and the right side of the deleted substring to concatenate together.
We repeatedly make k duplicate removals on s until we no longer can.
Return the final string after all such duplicate removals have been made. It is guaranteed that the answer is unique.
Example 1:
Input: s = "abcd", k = 2 Output: "abcd" Explanation: There's nothing to delete.
Example 2:
Input: s = "deeedbbcccbdaa", k = 3 Output: "aa" Explanation: First delete "eee" and "ccc", get "ddbbbdaa" Then delete "bbb", get "dddaa" Finally delete "ddd", get "aa"
Example 3:
Input: s = "pbbcggttciiippooaais", k = 2 Output: "ps"
Constraints:
 1 <= s.length <= 105
 2 <= k <= 104
 s only contains lower case English letters.
33. LeetCode 1029
A company is planning to interview 2n people. Given the array costs where costs[i] = [aCosti, bCosti], the cost of flying the ith person to city a is aCosti, and the cost of flying the ith person to city b is bCosti.
Return the minimum cost to fly every person to a city such that exactly n people arrive in each city.
Example 1:
Input: costs = [[10,20],[30,200],[400,50],[30,20]] Output: 110 Explanation: The first person goes to city A for a cost of 10. The second person goes to city A for a cost of 30. The third person goes to city B for a cost of 50. The fourth person goes to city B for a cost of 20. The total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interviewing in each city.
Example 2:
Input: costs = [[259,770],[448,54],[926,667],[184,139],[840,118],[577,469]] Output: 1859
Example 3:
Input: costs = [[515,563],[451,713],[537,709],[343,819],[855,779],[457,60],[650,359],[631,42]] Output: 3086
Constraints:
 2 * n == costs.length
 2 <= costs.length <= 100
 costs.length is even.
 1 <= aCosti, bCosti <= 1000
34. LeetCode 139
35. 图的遍历
图的遍历，找到并打印所有从A到B的路径。我用回溯/dfs做的，
36. 二叉树的遍历
二叉树的遍历，并将当前节点的next指向右侧节点
37. 移除链表值相同的相邻节点
移除链表值相同的相邻节点
38. LeetCode 151
39. LeetCode 155