- 博客(11)
- 收藏
- 关注
原创 leetcode练习 House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house
2018-01-26 16:50:33 180
原创 关于一个NP完全问题的证明
这里给出的例子是教材《算法概论》P267的8.14。题目: Prove that the following problem is NP-complete: given an undirected graph G = (V, E) and an integer k, return a clique of size k as well as an independent set of size k
2018-01-20 12:04:44 464
原创 leetcode练习 Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if yo
2018-01-10 15:45:13 147
原创 leetcode练习 Maximum Length of Repeated Subarray
Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.Example:Input:A: [1,2,3,2,1]B: [3,2,1,4,7]Output: 3Explanation: The repeated subarray wi
2018-01-09 21:04:28 188
原创 leetcode练习 Delete and Earn
Given an array nums of integers, you can perform operations on the array.In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every element equal to n
2018-01-07 22:02:13 331
原创 leetcode练习 Min Cost Climbing Stairs
再次进入动态规划的学习,先选了一道easy的题目,果然一次过。。。class Solution {public: int minCostClimbingStairs(vectorint>& cost) { vectorint> step; step.resize(cost.size()); for (int i = 0; i < cos
2018-01-05 21:48:57 198
原创 关于《算法概论》中,使用dfs对图进行标记的操作的实践
其实本身是在做leetcode 685. Redundant Connection II 题目说一定以根节点开头,但实际好像并非如此…感觉被坑了。 原先的思路是利用书中所说的dfs,选好根节点,进行pre和post标记,根据每个节点的标记判断前向边,横跨边,回边。 不过测试会出现第一个边是需要删除的边的情况。。。就权当对bfs的边判断的练手了class Solution {pu
2018-01-05 20:42:00 414
转载 欢迎使用CSDN-markdown编辑器(版本更新?。。。)
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I
2018-01-05 20:11:46 451
原创 leetcode练习 Reconstruct Itinerary
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the
2018-01-03 21:53:27 262
原创 leetcode练习 Evaluate Division
Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer do
2018-01-02 22:57:10 171
原创 leetcode练习 Network Delay Time
There are N network nodes, labelled 1 to N.Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, v is the target node, and w is the time it takes for a
2018-01-01 20:53:49 233
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人