![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法课程周更
小豪666
这个作者很懒,什么都没留下…
展开
-
sicily考试模拟题-1000超级和 1001会议室安排 1002二叉树比较
1000题目描述Description定义超级和函数F如下:F(0, n) = n,对于所有的正整数n..F(k, n) = F(k – 1, 1) + F(k – 1, 2) + … + F(k – 1, n),对于所有的正整数k和n.请实现下面Solution类中计算F(k, n)的函数(1 <= k, n <= 14).class Solution {public: int原创 2017-06-29 18:26:07 · 269 阅读 · 0 评论 -
leetCode刷题归纳-Dynamic Programming(62. Unique Paths)
题目描述 A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is trying原创 2017-06-10 12:59:50 · 182 阅读 · 0 评论 -
leetCode刷题归纳-Dynamic Programming( 63. Unique Paths II)
题目描述 Follow up for “Unique Paths”: Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectiv原创 2017-06-10 13:06:49 · 226 阅读 · 0 评论 -
leetCode刷题归纳-Dynamic Programming(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 [原创 2017-06-10 13:16:03 · 188 阅读 · 0 评论 -
leetCode刷题归纳-Dynamic Programming(64. Minimum Path Sum)
题目描述 Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either do原创 2017-06-10 13:46:55 · 170 阅读 · 0 评论 -
leetCode刷题归纳-Dynamic Programming(53. Maximum Subarray&& 152. Maximum Product Subarray)
题目描述 Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray原创 2017-06-10 13:54:28 · 216 阅读 · 0 评论 -
leetCode刷题归纳-Dynamic Programming(85. Maximal Rectangle)
题目描述 Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area. For example, given the following matrix: 1 0 1 0 0 1原创 2017-06-10 14:08:52 · 185 阅读 · 0 评论 -
leetCode刷题归纳-backtracking(39. Combination Sum I && II)
题目描述:39. Combination Sum I Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.原创 2017-06-10 14:33:21 · 196 阅读 · 0 评论 -
leetCode刷题归纳-backtracking(79. Word Search)
题目描述 Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or原创 2017-06-10 14:41:28 · 215 阅读 · 0 评论 -
leetCode刷题归纳-Array(216. Combination Sum III)
这一题有点小复杂。。。。主要是递归算法的设计比较考验编程能力。。。没有时空间复杂度的要求,使用递归也比较方便理解,题目描述如下,大概就是使得k个1-9的数之和为n;代码贴到下面,好好理解: Example 1: Input: k = 3, n = 7 Output: [[1,2,4]] Example 2: Input: k原创 2017-04-30 20:01:46 · 147 阅读 · 0 评论 -
leetCode刷题归纳-Dynamic Programming(514. Freedom Trail)
题目描述 In the video game Fallout 4, the quest “Road to Freedom” requires players to reach a metal dial called the “Freedom Trail Ring”, and use the dial to spell a specific keyword in order to open the原创 2017-06-10 12:43:45 · 285 阅读 · 0 评论 -
leetCode刷题归纳-Divide and Conquer(241. Different Ways to Add Parentheses)
Divide的题目相比起来难度会比较大,主要是分治的思想比较难以与实际应用结合起来,下面是题目描述: Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and opera原创 2017-03-19 18:44:16 · 233 阅读 · 0 评论 -
sicily考试模拟题-1003相连的1 1004isDAG? 1005相邻的数 1006单词变换
1003相连的1题目描述对于一个01矩阵A,求其中有多少片连成一片的1. 每个1可以和上下左右的1相连.请为下面的Solution类实现解决这一问题的函数countConnectedOnes,函数参数A为给出的01矩阵,A的行数和列数均不大于1000. 函数的返回值是问题的答案.class Solution {public: int countConnectedOnes(vector<ve原创 2017-06-29 18:38:38 · 368 阅读 · 0 评论 -
证明题-算法概论8.3吝啬SAT问题证明
问题描述吝啬SAT问题是这样的:给定一组子句(每个子句都是其中文字的析取)和整数k,求一个最多有k个变量为true的满足赋值——如果该赋值存在。证明吝啬问题是NP-完全问题。解题思路1.什么是SAT问题假设我们有这样一组子句: (a⋃b⋃c)⋂(a⋃b¯)⋂(b⋃c¯)(a¯⋂c)⋂(a¯⋃b¯⋃c¯) 我们需要做的就是找到a,b,c的取值(true or false)使得该表达式的结果是tr原创 2017-06-29 23:23:23 · 351 阅读 · 0 评论 -
leetCode刷题归纳-Array(448. Find All Numbers Disappeared in an Array Add to List)
很有意思的思路,采用标记负值的方法解决,如果出现过就标记为负数,最后检测正数的位置,其索引值对应的就是没有出现过的位置。 Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the原创 2017-05-07 18:42:06 · 172 阅读 · 0 评论 -
leetCode刷题归纳-Array(74. Search a 2D Matrix)
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of原创 2017-04-23 20:32:09 · 156 阅读 · 0 评论 -
网易2017笔试题-日记的颜色
题目描述最近面试做了一个笔试题,感觉还挺有收获的。输入输出样例输入例子:2 <diary><color=red>I am happy.<color=blue>I am sad.</color>I am happy.</color>This is black.</diary> <diary><color=ab>12</color><color=a>12</color><color=aa>原创 2017-04-16 18:44:41 · 485 阅读 · 0 评论 -
leetCode刷题归纳-List(25. Reverse Nodes in k-Group)
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the n原创 2017-04-23 20:28:03 · 181 阅读 · 0 评论 -
leetCode刷题归纳-Divide and Conquer(215. Kth Largest Element in an Array)
题目描述 Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For example, Given [3,2,1,5,6,4] and原创 2017-03-24 18:09:58 · 328 阅读 · 0 评论 -
leetCode刷题归纳-Divide and Conquer(312. Burst Balloons)
这个是比较久之前写的题了,今天刚好复习又看到。 虽然被归类到DC分类,但是比较明显的DP算法题(个人感觉),题目描述就不写了,直接上Example: Example: Given [3, 1, 5, 8] Return 167nums = [3,1,5,8] --> [3,5,8] --> [3,8] --> [8] --> [] coins = 3*1原创 2017-03-19 20:14:29 · 257 阅读 · 0 评论 -
leetCode刷题归纳-List(148 Sort List)
题目标题是148. Sort List中等难度,但是需要用到divide & conquer的思想,个人感觉还是比较有难度,题目描述如下: Sort a linked list in O(n log n) time using constant space complexity.要求时间复杂度为O(n log n)空间复杂度为O(1),分析可知,只能用分治的思想来完成才能达到要求,因为只有分治原创 2017-03-12 13:20:27 · 239 阅读 · 1 评论 -
leetCode刷题归纳-linked list(141. Linked List Cycle&& Add to List 142. Linked List Cycle II)
这一题还蛮有意思的,虽然不太复杂,但是也是一种很简便的算法思想,所以在此做一下记录题目描述: 141. Linked List Cycle I Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? Subscr原创 2017-06-10 14:58:36 · 289 阅读 · 0 评论