c/c++
T-tss玄
学习的孩子
展开
-
eclipse 出现Launch failed.Bianry not found问题处理
许多朋友,原创 2014-08-12 08:06:42 · 2701 阅读 · 1 评论 -
Leetcode Container With Most Water
Leetcode Container With Most Water ,本算法的主要原理是从前两个方向进行扫描,保存最大的,并且在缩减范围,依据丢弃较小值的原则,相关cpp代码与测试如下:#include<iostream>#include<vector>using namespace std;// First we calculate the front till the end as the原创 2015-10-29 13:34:33 · 358 阅读 · 0 评论 -
Leetcode Set Matrix Zeroes
Leetcode Set Matrix Zeroes 相关代码,应题目要求,本方法的空间复杂度为O(1),时间复杂度为O(m * n),cpp代码以及测试如下:#include<iostream>#include<vector>using namespace std;// For the O(1) space constraint, we use the first row and the fir原创 2015-10-20 21:48:38 · 453 阅读 · 0 评论 -
Leetcode Sort Colors
Leetcode Sort Colors 本题相对简单,主要思想为通过交换元素,把’0’交换到开头,把’2’交换到结尾,这样中间就是’1’了,本算法复杂度为o(1), 以下结出相关代码,代码使用cpp:#include<iostream>#include<vector>using namespace std;// We swap the '0' to the start of the array,原创 2015-10-20 09:35:08 · 381 阅读 · 0 评论 -
Leetcode Spiral Matrix II
Leetcode Spiral Matrix II 相关代码,本代码重用了Spiral Matrix 的相关代码。以下给出可运行代码,以及测试:#include<iostream>#include<vector>using namespace std;class Solution {public: vector<vector<int> > generateMatrix(int n) {原创 2015-10-20 00:06:15 · 398 阅读 · 0 评论 -
Leetcode Spiral Matrix
Leetcode Spiral Matrix 相关代码,本方法比较简单,只是记录上下左右的偏移,并通过横向与纵向某一个方向成来结束构造,本代码使用cpp完成,并提供测试:#include<iostream>#include<vector>using namespace std;class Solution {public: vector<int> spiralOrder(vector<v原创 2015-10-19 17:02:16 · 566 阅读 · 0 评论 -
Leetcode Subsets II
Leetcode Subsets II,本问题与Subsets 类似,只是需要处理重复子集问题,这个问题,我们可以使用每次从长度为m的子集构成长度为m+1的子集时,只对等值的元素添加一次,这样就可以保证没有重复现象,处理代码与Subsets类似,如下:#include<iostream>#include<vector>#include<algorithm>using namespace std;原创 2015-10-19 09:46:57 · 387 阅读 · 0 评论 -
Leetcode Minimum Path Sum
Leetcode Minimum Path Sum 相关代码,使用dp算法完成,使用down-up方法完成,并提供简单的测试。#include <iostream>#include <vector>using namespace std;class Solution {public: int minPathSum(vector<vector<int> >& grid) {原创 2015-09-09 00:54:54 · 348 阅读 · 0 评论 -
Leetcode Triangle
Leetcode Triangle 相关代码,使用dp方法完成,c++代码如下,并提供简单的测试代码。#include <iostream>#include <unordered_set>#include <vector>#include <string>using namespace std;class Solution {public: int minimumTotal(vec原创 2015-09-08 23:04:50 · 383 阅读 · 0 评论 -
Leetcode Unique Binary Search Trees
Leetcode Unique Binary Search Trees 代码,本代码使用down-up方法,并打印了相关信息,使用c++,如下:#include <iostream>#include <vector>using namespace std;class Solution {public: int numTrees(int n) { vector<int>原创 2015-09-01 23:26:43 · 454 阅读 · 0 评论 -
linux内核const.h文件解释
文件路径:Linux/arch/x86/include/asm/pgtable_types.h文件内容如下:/* const.h: Macros for dealing with constants. */#ifndef _LINUX_CONST_H#define _LINUX_CONST_H/* Some constant macros are used in原创 2015-01-06 00:44:28 · 1599 阅读 · 0 评论 -
关于c++常量函数(const member function)
在c++ primer中对于常最函数的解析如下:By default, the type of this is a const pointer to nonconst version of the class type. However, in the case, we cannot bind this to a const object. And means we cannot call an原创 2016-10-29 20:30:24 · 2088 阅读 · 0 评论