- 博客(164)
- 资源 (11)
- 收藏
- 关注
原创 MIT6.824-Lab1
一、介绍通过阅读MapReduce论文,在本地实现一个分布式MapReduce。课程提供的代码中需要修改的有三处(mr/coordinator.go, mr/worker.go, mr/rpc.go),其中coordinator.go就是论文中的master角色,rpc.go中定义rpc通信需要的一些结构。二、实现流程coordinator根据用户传进来的inputs(pg-*.txt)生成Nmap个Map任务。(我是一个文件生成一个Map任务,也可自行定义,作业未对Map个数作硬性规定) w
2021-03-17 15:52:25
1936
1
原创 143. Reorder List
Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You maynotmodify the values in the list's nodes, only nodes itself may be changed.Example 1:Given 1->2-...
2019-07-22 23:15:47
248
原创 142. Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.To represent a cycle in the given linked list, we use an integerposwhich represents the position (0-i...
2019-07-22 21:36:47
237
原创 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integerposwhich represents the position (0-indexed)in the linked list where tail co...
2019-07-22 20:58:39
234
原创 140. Word Break II
Given anon-emptystringsand a dictionarywordDictcontaining a list ofnon-emptywords, add spaces insto construct a sentence where each word is a valid dictionary word.Return all such possible s...
2019-07-22 20:05:00
139
原创 139. Word Break
Given anon-emptystringsand a dictionarywordDictcontaining a list ofnon-emptywords, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.Note:The s...
2019-07-21 23:00:28
163
原创 138. Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return adeep copyof the list.Example 1:Input:{"$id":"1...
2019-07-21 21:24:48
164
原创 136. Single Number
Given anon-emptyarray of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without us...
2019-07-12 21:55:13
138
原创 135. Candy
There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one ca...
2019-07-12 21:11:11
150
原创 134. Gas Station
There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it costscost[i]of gas to travel from stationito its ...
2019-07-11 22:21:46
120
原创 133. Clone Graph
Givena reference of a node in aconnectedundirected graph, return adeep copy(clone) of the graph. Each node in the graph contains a val (int) and a list (List[Node]) of its neighbors.Example:...
2019-07-11 21:34:11
198
转载 132. Palindrome Partitioning II
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs.Example:Input:"aab"Output: 1Explana...
2019-07-11 20:34:50
144
转载 131. Palindrome Partitioning
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.Example:Input:"aab"Output:[ ["aa","b"], ["a","a"...
2019-07-11 16:24:05
167
原创 130. Surrounded Regions
Given a 2D board containing'X'and'O'(the letter O), capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region.Example:X X X XX O O...
2019-07-05 15:12:50
123
原创 129. Sum Root to Leaf Numbers
Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents the number123.Find the tota...
2019-07-05 14:35:12
160
原创 128. Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.Example:Input:[100, 4, 200, 1, 3, 2]Output: 4Ex...
2019-07-05 11:49:55
139
转载 127. Word Ladder
Given two words (beginWordandendWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWordtoendWord, such that:Only one letter can be changed at a ti...
2019-07-05 10:14:21
150
原创 125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note:For the purpose of this problem, we define empty string as valid palindrome.Examp...
2019-07-04 16:45:56
155
原创 124. Binary Tree Maximum Path Sum
Given anon-emptybinary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connectio...
2019-07-04 16:30:17
147
原创 123. Best Time to Buy and Sell Stock III
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at mosttwotransactions.Note:You may not en...
2019-07-04 15:35:28
159
原创 122. Best Time to Buy and Sell Stock II
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy on...
2019-07-04 14:21:55
126
原创 121. Best Time to Buy and Sell Stock
Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock),...
2019-07-04 13:54:08
177
原创 117. Populating Next Right Pointers in Each Node II
Given a binary treestruct 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 point...
2019-07-04 13:41:44
140
原创 120. Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5...
2019-06-27 21:26:57
112
原创 119. Pascal's Triangle II
Given a non-negativeindexkwherek≤33, return thekthindex row of the Pascal's triangle.Note that the row index starts from0.In Pascal's triangle, each number is the sum of the two numbers ...
2019-06-27 20:11:20
136
原创 118. Pascal's Triangle
Given a non-negative integernumRows, generate the firstnumRowsof Pascal's triangle.In Pascal's triangle, each number is the sum of the two numbers directly above it.Example:Input: 5Output:[...
2019-06-27 20:02:27
122
原创 116. Populating Next Right Pointers in Each Node
You are given aperfect binary treewhereall 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; ...
2019-06-27 19:44:25
140
原创 115. Distinct Subsequences
Given a stringSand a stringT, count the number of distinct subsequences ofSwhich equalsT.A subsequence of a string is a new string which is formed from the original string by deleting some (ca...
2019-06-27 19:08:47
192
原创 114. Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \ \3 4 6The flattened tree should look like:1 \ 2 \ ...
2019-06-27 16:02:27
111
原创 113. Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Note:A leaf is a node with no children.Example:Given the below binary tree andsum = 22,...
2019-06-27 15:34:41
113
原创 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note:A leaf is a node with no children.Example:...
2019-06-27 14:53:36
120
原创 111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note:A leaf is a node with no childre...
2019-06-27 14:39:09
109
原创 110. Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees ofeverynode never diff...
2019-06-23 00:04:35
111
原创 109. Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the ...
2019-06-22 23:28:52
110
原创 108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the...
2019-06-22 23:23:08
129
原创 107. Binary Tree Level Order Traversal II
Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree[3,9,20,null,null,15,7...
2019-06-22 22:52:19
141
原创 106. Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, giveninorder =[9,3,15,20,7]postorder = [9...
2019-06-22 22:17:59
142
原创 1007 Maximum Subsequence Sum(25 分)
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequen...
2018-08-28 22:55:19
270
原创 问题 C: 畅通工程
题目描述省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。输入测试输入包含若干测试用例。每个测试用例的第1行给出评估的道路条数 N、村庄数目M (N, M < =100 );随后的 N 行对应村庄...
2018-08-26 23:37:34
506
原创 问题 A: 还是畅通工程
题目描述 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。输入 测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( < 100 );随后的N(N-1)...
2018-08-26 23:32:18
405
Coursea平台-普林斯顿大学-Algorithms-II-第四周-Boggle编程作业
2020-02-28
Coursea平台-普林斯顿大学-Algorithms-II-第三周-Baseball Elimination编程作业
2020-02-25
Coursea平台-普林斯顿大学-Algorithms-II-第二周-SeamCarver编程作业
2020-02-22
Coursea平台-普林斯顿大学-Algorithms-I-第五周-Kd-Trees编程作业-满分
2020-02-13
魔兽世界三(开战)-北京大学-C++程序设计与算法
2020-02-11
利用OpenCV2.1制作个人视频(加个人图片、字幕、暂停)
2019-11-24
Tcp通信(基于QT5.13 + TCP + 服务端 + 客户端)
2019-07-06
视频播放器(基于Qt5.13.0 + mplayer + win10)
2019-07-03
简易记事本小程序
2019-07-01
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人