自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(60)
  • 资源 (1)
  • 收藏
  • 关注

原创 Libsvm在linux系统的安装与使用

欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I...

2018-05-18 09:56:40 494

原创 Lintcode 装最多水的容器

装最多水的容器 思路: 容器大小由区间长度和高度共同决定。两个指针,从左右逼近,开始的时候,区间长度最大。然后调整长度,选择合适的高度。高度由最小的柱子决定。class Solution {public: /* * @param : a vector of integers * @return: an integer */ int maxArea(

2017-08-07 11:03:03 264

原创 Lintcode 插入区间

插入区间/** * Definition of Interval: * class Interval { * public: * int start, end; * Interval(int start, int end) { * this->start = start; * this->end = end; * } * }

2017-08-06 20:16:44 274

转载 Lintcode 乘积最大子序列

找出一个序列中乘积最大的连续子序列(至少包含一个数)。样例 比如, 序列 [2,3,-2,4] 中乘积最大的子序列为 [2,3] ,其乘积为6。分析:访问到每个点的时候,以该点为子序列的末尾的乘积,要么是该点本身,要么是该点乘以以前一点为末尾的序列,注意乘积负负得正,故需要记录前面的最大最小值。牛人代码:class Solution { public: /** * @p

2017-08-06 19:37:42 241

原创 Lintcode各位相加

思路: 各位相加,判断是否小于10; len 控制循环;class Solution {public: /** * @param num a non-negative integer * @return one digit */ int addDigits(int num) { // Write your code here

2017-08-05 21:12:53 189

原创 Lintcode矩阵之字型遍历

class Solution { public: /** * @param matrix: a matrix of integers * @return: a vector of integers */ vector<int> printZMatrix(vector<vector<int> > &matrix) {

2017-08-05 15:45:39 197

原创 Lintcode回文数

class Solution {public: /** * @param num a positive number * @return true if it's a palindrome or false */ bool palindromeNumber(int num) { // Write your code here

2017-08-05 10:56:45 162

原创 Lintcode 丢失的第一个正整数

思路: 桶排序,每一个数放在该放的位置,1放在第1个位置,2放在第2个位置,n放在第n个位置 注意!!!坐标从0开始, 5放在下标为4 个位置,i放在下标为i-1 的位置。class Solution {public: /** * @param A: a vector of integers * @return: an integer */

2017-08-04 20:34:37 193

原创 Lintcode 第一个错误版本

/** * class SVNRepo { * public: * static bool isBadVersion(int k); * } * you can use SVNRepo::isBadVersion(k) to judge whether * the kth code version is bad or not.*/class Solution {p

2017-08-04 10:51:33 511

原创 LIntcode 数组划分

思路想到了,自己的代码区间有问题!以后要自己调bug下面是ac代码;class Solution {public: int partitionArray(vector<int> &nums, int k) { // write your code here int len=nums.size(); int temp=0; in

2017-08-03 19:19:18 165

转载 Lintcode 颜色排序2

class Solution{public: /** * @param colors: A list of integer * @param k: An integer * @return: nothing */ void sortColors2(vector<int> &colors, int k) { // wri

2017-08-02 19:53:56 175

原创 Lintcode三角形计数

自己写的代码,简单粗暴,但是超时。class Solution {public: /* * @param : A list of integers * @return: An integer */ int triangleCount(vector<int> S) { // write your code here int

2017-08-02 17:30:31 203

原创 Lintcode翻转链表

翻转链表 /** * Definition of ListNode * * class ListNode { * public: * int val; * ListNode *next; * * ListNode(int val) { * this->val = val; * this->next = NULL; *

2017-08-02 16:04:44 175

原创 Lintcode合并排序数组 II

牛人代码;思路很新颖;class Solution {public: /** * @param A: sorted integer array A which has m elements, * but size of A is m+n * @param B: sorted integer array B which has n elem

2017-08-02 15:23:49 149

原创 Lintcode 删除排序数组中的重复数字

删除排序数组中的重复数字 自己的方法有点复杂,下面是牛人的代码,简洁高效;class Solution {public: /** * @param A: a list of integers * @return : return an integer */ int removeDuplicates(vector<int> &nums) {

2017-08-01 19:20:09 157

原创 LIntcode 子数组之和

子数组之和class Solution {public: /** * @param nums: A list of integers * @return: A list of integers includes the index of the first number * and the index of the last number

2017-08-01 17:29:11 184

转载 Lintcode落单的数 删除排序数组中的重复数字 II

http://www.wengweitao.com/lintcode-single-number-i-ii-iii-luo-dan-de-shu.html

2017-08-01 16:58:53 188

原创 Lingcode 整数转罗马数字

整数转罗马数字class Solution {public: /** * @param n The integer * @return Roman representation */ string intToRoman(int n) { // Write your code here public static String in

2017-08-01 09:32:57 223

原创 二叉树遍历

后序遍历/** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this->val = val; * this->left = this->rig

2017-07-31 21:15:53 127

原创 最长公共子序列

最长公共子序列动态规划 !!!!!!!!!!!!!!给出两个字符串,找到最长公共子序列(LCS),返回LCS的长度。您在真实的面试中是否遇到过这个题? Yes 说明 最长公共子序列的定义:最长公共子序列问题是在一组序列(通常2个)中找到最长公共子序列(注意:不同于子串,LCS不需要是连续的子串)。该问题是典型的计算机科学问题,是文件差异比较程序的基础,在生物信息学中也有所应用。 样例 给出

2017-07-31 17:14:46 176

原创 lintcode Permutation Index

class Solution { public: /** * @param A an integer array * @return a long integer */ long long permutationIndex(vector<int>& A) { // Write your code here

2017-07-31 17:12:38 152

原创 Lintcode 主元素

主元素1class Solution {public: /** * @param nums: A list of integers * @return: The majority number */ int majorityNumber(vector<int> nums) { // write your code here

2017-07-30 17:04:34 273 1

转载 Lintcode 背包问题

牛人代码Backpack IProblem 单次选择+最大体积Given n items with size Ai, an integer m denotes the size of a backpack. How full you can fill this backpack?NoticeYou can not divide any item into small pieces.Exampl

2017-07-29 20:12:50 260

转载 文章标题

/** * Definition of ListNode * class ListNode { * public: * int val; * ListNode *next; * ListNode(int val) { * this->val = val; * this->next = NULL; * } * } *

2017-07-29 19:55:19 119

转载 Lintcode 加油站

加油站转载别人的代码, 没看懂!class Solution {public: /** * @param gas: a vector of integers * @param cost: a vector of integers * @return: an integer */ int canCompleteCircuit(vector<i

2017-07-29 16:57:58 169

转载 Lintcode 房屋染色

这里有n个房子在一列直线上,现在我们需要给房屋染色,分别有红色蓝色和绿色。每个房屋染不同的颜色费用也不同,你需要设计一种染色方案使得相邻的房屋颜色不同,并且费用最小。 费用通过一个nx3 的矩阵给出,比如cost[0][0]表示房屋0染红色的费用,cost[1][2]表示房屋1染绿色的费用class Solution {public: /** * @param cost

2017-07-29 15:19:36 229

原创 LintCode 二分查找

在一个排序数组中找一个数,返回该数出现的任意位置,如果不存在,返回-1您在真实的面试中是否遇到过这个题? Yes 样例 给出数组 [1, 2, 2, 4, 5, 5].对于 target = 2, 返回 1 或者 2. 对于 target = 5, 返回 4 或者 5. 对于 target = 6, 返回 -1.class Solution {public: /**

2017-07-29 13:18:35 176

转载 Lintcode 跳跃游戏

给出一个非负整数数组,你最初定位在数组的第一个位置。   数组中的每个元素代表你在那个位置可以跳跃的最大长度。    判断你是否能到达数组的最后一个位置。样例 A = [2,3,1,1,4],返回 true.A = [3,2,1,0,4],返回 false.分析:遍历一遍,记录可走的点可以达到的最远点牛人算法!!!!class Solution { public: /**

2017-07-28 20:48:24 174

原创 Lintcode 最小差

运算超时class Solution {public: /** * @param A, B: Two integer arrays. * @return: Their smallest difference. */ int smallestDifference(vector<int> &A, vector<int> &B) { // w

2017-07-28 19:21:39 129

转载 Lintcode n皇后问题

N皇后问题是一个经典的问题,在一个N*N的棋盘上放置N个皇后,每行一个并使其不能互相攻击(同一行、同一列、同一斜线上的皇后都会自动攻击)。一、 求解N皇后问题是算法中回溯法应用的一个经典案例 回溯算法也叫试探法,它是一种系统地搜索问题的解的方法。回溯算法的基本思想是:从一条路往前走,能进则进,不能进则退回来,换一条路再试。 在现实中,有很多问题往往需要我们把其所有可能穷举出来,

2017-07-28 17:18:44 253

转载 Lintcode 硬币排成线

http://www.jianshu.com/p/42656455eefc 这篇文章分析的很好!class Solution { public: /** * @param values: a vector of integers * @return: a boolean which equals to true if the first player wil

2017-07-28 15:49:39 277

原创 Lintcode 字符大小写排顺序

字符大小写排顺序思路: 小写字母在前,大写在后。 1,依次遍历,遇到小写,继续。 2,遇到大写字母将其存储在temp中,从后面依次遍历遇到小写字母,交换。 3,交换后,从原始大写字母后一位,开始遍历。 j++class Solution { public: /** * @param chars: The letters array you should sort

2017-07-28 14:56:09 222

原创 Lintcode 买卖股票的最佳时机

买卖股票的最佳时机思路: 最大利润 为当前值- 前面最小值 1 lowest =prices[0],记为最小值,循环一次,记min(lowest,prices[i])为最小值; 2 profit= max(profit,prices[i] - lowest);profit 初值为0;class Solution {public: /** * @param prices: Gi

2017-07-28 11:11:44 210

原创 LintCode Guess Number Game II

二分法,这道题还是有难度的!class Solution { public: int getMoneyAmount(int n) { vector<vector<int>> dp(n+1, vector<int>(n+1, 0)); //创建装有n+1个容器的容器,该容器所装容器的初始值为n+1个0; for(int i = n

2017-07-27 22:00:03 242

翻译 LingCode Range Sum Query 2D - Immutable

Range Sum Query 2D - Immutable 牛人的代码,备忘学习一下class NumMatrix {public: vector<vector<int>> dp; int n, m; NumMatrix(vector<vector<int>> matrix) { n = matrix.size(); if(n > 0 &

2017-07-26 20:06:00 183

原创 LintCode C++代码Two Sum - Input array is sorted

Two Sum - Input array is sorted 思路:双循环class Solution {public: /* * @param nums an array of Integer * @param target = nums[index1] + nums[index2] * @return [index1 + 1, index2 + 1]

2017-07-24 17:36:59 131

原创 Lintcode 代码

Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST. 思路:中序遍历

2017-07-20 11:32:16 370

原创 LintCode 旋转字符串

没有通过,不知道什么原因!class Solution {public: void recoverRotatedSortedArray(vector<int> &nums) { // write your code here int n = nums.size(); int m = 0 , i = 0; for (i = 0;

2017-07-20 09:58:30 199

原创 LintCode C++代码旋转字符串

给定一个字符串和一个偏移量,根据偏移量旋转字符串(从左向右旋转) 思路: 1 判断 字符串 或者offset 是否为0; 2 offset 大于字符串长度的时候。offset%str.size(); 3,循环前移。class Solution {public: /** * @param str: a string

2017-07-19 21:40:27 182

原创 LintCode 代码 翻转数

将一个整数中的数字进行颠倒,当颠倒后的整数溢出时,返回 0 (标记为 32 位整数)。class Solution {public: /** * @param n the integer to be reversed * @return the reversed integer */ int reverseInteger(int n) {

2017-07-18 19:42:43 212

deep learning with Python

keras 作者FRANÇOIS CHOLLET 非常好用的书籍 适合初学者

2018-05-05

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除