- 博客(21)
- 收藏
- 关注
原创 中山大学算法课程题目详解(第十九周)NP问题
问题描述: 吝啬SAT问题是这样的:给定一组子句(每组子句都是其中文字的析取)和整数k,求一个最多有k个变量为true的满足赋值–如果该赋值存在,证明吝啬SAT是NP-完全问题。 解决思路以及方法: 我们很容易知道吝啬SAT的解是可在多项式时间内验证的,因此属于NP问题。 此外,我们可以将SAT规约到吝啬SAT(将k设为所有变量的总个数即可),因为吝啬SAT为NP完全问题。
2018-01-14 13:39:43
396
原创 中山大学算法课程题目详解(第十八周)
问题描述: 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.
2018-01-10 15:35:27
385
原创 中山大学算法课程题目详解(第十七周)
问题描述: Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you w
2018-01-06 16:52:10
545
原创 中山大学算法课程题目详解(第十六周)
问题描述: Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Ex
2018-01-06 16:45:59
349
原创 中山大学算法课程题目详解(第十五周)
问题描述: 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 in ascending from left to right.I
2018-01-06 16:42:16
533
原创 中山大学算法课程题目详解(第十四周)
问题描述: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, Given n = 3, there are a total of 5 unique BST's. 1 3 3 2
2017-12-28 15:10:35
229
原创 中山大学算法课程题目详解(第十三周)
问题描述: 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 down
2017-12-28 09:23:04
223
原创 关于golang使用mysql以及docker的一些坑
一、关于mysql数据库权限的问题 首先,在使用mysql的时候,我们新建一个数据库,并且在数据库新建一个表格后,一般我们会新建一个用户,然后使用该用户对该数据库进行管理,这时候我们必须对于该用户赋予操作该数据库的相关权限,具体有以下几种权限以及对应操作。没有赋予权限时候,golang对于数据库的操作都会报Access Denied的错误。关于mysql的安装以及配置可以借鉴以下博客
2017-12-06 19:20:18
2624
原创 中山大学算法课程题目详解(第十二周)
问题描述: 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 respectivel
2017-12-06 18:51:20
245
原创 中山大学算法课程题目详解(第十一周)
问题描述: 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 to r
2017-12-06 18:43:12
268
原创 中山大学算法课程题目详解(第十周)
问题描述: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions. Note:
2017-11-27 18:49:17
334
原创 中山大学算法课程题目详解(第九周)
问题描述: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of
2017-11-27 18:42:13
242
原创 中山大学算法课程题目详解(第八周)
问题描述: There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal
2017-11-03 09:25:45
294
原创 Golang基本工具的安装以及cobra的安装
golang基本工具的安装: 第一种方法:假设你已经有用于翻墙的VPN,梯子比较高,那对于golang基本工具的安装还是挺容易的,只要执行以下命令: go get -u golang.org/x/tools/cmd/goimports go get -u golang.org/x/tools/cmd/gorename go get -u github.com/sqs/goreturns g
2017-11-01 20:25:15
4112
原创 中山大学算法课程题目详解(第七周)
问题描述: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you l
2017-10-23 14:00:48
289
原创 中山大学算法课程题目详解(第六周)
问题描述: Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum
2017-10-22 16:37:25
308
原创 中山大学算法课程题目详解(第五周)
问题描述: 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.
2017-10-12 16:34:33
275
原创 中山大学算法课程题目详解(第四周)
问题描述: There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is ex
2017-09-30 14:01:47
363
原创 中山大学算法课程题目详解(第三周)
问题描述: 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 k = 2,
2017-09-23 12:33:57
278
原创 中山大学算法课程题目详解(第二周)
问题描述: 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 [4
2017-09-16 16:03:51
330
原创 中山大学算法课程题目详解(第一周)
问题描述: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not
2017-09-10 19:12:25
380
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅