- 博客(49)
- 资源 (23)
- 收藏
- 关注
原创 Leetcode Linked List Cycle
Given a linked list, determine if it has a cycle in it.使用两个指针,一前一后,(p,q),p与q相差一个位置,之后p移动一步,q相对应移动两步,如果存在环,那么q和p一定会相遇/** * Definition for singly-linked list. * struct ListNode { * int val;
2015-05-29 22:07:52 350
原创 Leetcode Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.class Solution {public: int strStr(string haystack, string need
2015-05-29 09:54:32 274
原创 C++ string类型和char类型转换
在C++常用的字符串对象类string,有很多实用的类成员函数,比如求字符串的长度,查找字符串的子串,字符串连接等等我们使用C语言的一些处理字符串的函数的时候,由于我们使用的是string类对象,所以需要转化一下,由string-->char类型转换这时候需要时候c_str()函数,作用就是实现string-->char的转换。
2015-05-29 09:48:24 648
原创 torch7 install 环境搭建
1、before intallation,you should install node.js,gfx.jsNode.js是一个软件平台,通常用于构建大规模的服务器端应用。Node.js使用JavaScript作为其脚本语言,由于其非阻塞I/O设计以及单线程事件循环机制,使得它可以交付超高的性能。 Node.js包含了Google V8 JavaScript引擎,libuv库和核心
2015-05-27 09:00:39 7330 1
原创 Leetcode Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node./** * Definition for a binary tree
2015-05-26 09:54:35 373
原创 Leetcode Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]杨辉三角的特点class Solutio
2015-05-25 09:49:35 309
原创 从Linux系统拷贝的文本文件到windows下出现乱码
从Linux系统拷贝的文本文件到windows下,用记事本打开的时候出现乱码,但是发现用写字板打开的时候显示正常,很奇怪?之后用写字板打开文件-》另存为,保存类型选择Unicode文本文档,发现再次用记事本打开的时候一切显示正常了。出现这种情况的原因为两种操作系统的中文压缩方式不同,在windows环境中中文压缩一般为gbk,而在linux环境中为utf8,这就导致了在windows下
2015-05-23 19:36:23 2649
原创 Leetcode 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 k = 2, return 5
2015-05-23 16:43:25 308
原创 Leetcode Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.题意是写一个函数,找到字符串最大相同的前缀。首先以第一个字符串的子串作为参考,依次和其它字符串子串比较,如果相同,则继续,不同则返回上一次的参考子串。class Solution {public: stri
2015-05-23 16:30:17 262
原创 Leetcode Pow(x, n)
Implement pow(x, n).题目是很简单,就是求x的n次方,但是提交的时候很费劲,TLE,超时,主要考虑一些条件问题:1、result 2、x = 1 或者-1的时候,返回值根据n的奇偶情况返回1或者-13、n = 0的情况,返回值1.4、n不能直接累积,肯定会超时,因此要成倍的累积。class Solution {public: double myPo
2015-05-23 09:35:46 273
原创 Leetcode Rotate Array
Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].数组的旋转问题,需要找到每一个位置对应旋转之后的位置,保存为 itoj 数组,然后需要申请
2015-05-22 21:53:44 347
原创 Leetcode Reverse Bits
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as0011100101
2015-05-22 20:46:24 363
原创 Leetcode Number of 1 Bits
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 000000
2015-05-22 20:21:50 281
原创 Leetcode Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is
2015-05-22 10:46:02 304
原创 Leetcode 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact
2015-05-18 19:49:29 288
原创 Leetcode Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get
2015-05-18 19:47:26 275
原创 Leetcode Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
2015-05-18 19:45:05 236
原创 Leetcode Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".二进制数相加,主要是判断进位的问题,如何保存结果,字符如何转化成数字等,要考虑产生进位的情况,求和时要加上进位。class Solution {pub
2015-05-18 19:41:58 261
原创 Leetcode Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.用递归的思想做
2015-05-18 19:40:00 264
原创 Leetcode Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element
2015-05-18 19:36:38 201
原创 Leetcode Minimum Depth of Binary Tree
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */clas
2015-05-18 19:34:15 247
原创 Leetcode Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using e
2015-05-18 19:28:30 198
原创 Leetcode Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as
2015-05-18 19:25:25 336
原创 Leetcode Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers
2015-05-18 19:22:53 266
原创 Leetcode Reverse Linked List
Reverse a singly linked list.单链表反序,很简单...class Solution {public: ListNode* reverseList(ListNode* head) { ListNode * H=new ListNode(0); H->next=NULL; ListNode * p=head;
2015-05-18 19:18:37 248
原创 Leetcode Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it t
2015-05-18 19:12:41 223
原创 Leetcode Integer to Roman
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.题目意思:罗马数字转换成数字形式,第一次提交的时候出现超时,class Solution {public: string intToRoman(int n
2015-05-17 19:31:07 241
原创 Leetcode Count Primes
Description:Count the number of prime numbers less than a non-negative number, n题目意思就是统计1~n之间有多少素数。C语言教程中提到一种求素数的方法,如果X不能被2~sqrt(x)之间的数整除,则x是素数,但是这样会出现time limit out,超时,接下来要优化这种方法,就是记录已经找到
2015-05-17 15:06:44 212
原创 Leetcode Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, t
2015-05-17 10:36:26 185
原创 Leetcode Compare Version Numbers
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and co
2015-05-16 20:38:53 224
原创 Leetcode Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?爬楼梯问题,每一次可以爬1阶或者2阶,问爬上N阶的选择法
2015-05-16 19:03:39 278
原创 linux文件属性及权限修改
Linux文件的基本属性有9个,分别是owner/group/others组别的read/write/ excute属性r:4、w:2、x:1更改文件属性的命令 chmod1)同一组(owner/group/others)的3个属性(r/w/x)是需要累加的,例如当属性为 [-rwxrwx---] 则是:owner = rwx = 4+2+1 = 7group = rwx =
2015-05-16 18:33:07 453
原创 opencv的imread函数无法读取图像
今天在用OpenCV测试程序的时候发现imread函数无法读取图像,而利用C函数cvLoadImage时却能读取到图像。几经考证,发现的确是由于库关联的问题。也就是在Debug模式下应该选择带'd'的lib,在Release模式下就选择不带'd'的lib。而实际我们在配置OpenCV环境的时候往往图方便将Debug和Release的目录都一起加了进去,再修改起来也比较麻烦。所以这时候最简单
2015-05-16 18:28:43 3448
原创 C++中clock()函数的使用
函数声明:clock_t clock( void ); clock_t 是 long 型,typedef long clock_t;clock() 使用的头文件是:time.hCLOCK_PER_SEC表示每一秒经历的时钟数。通常我们用clock_t now = clock(); while(i--); finish = clock(); seconds = (f
2015-05-16 18:26:24 9523
原创 C++ 读文件为什么最后一个字符会多读一次
一般判断读文件的结束条件 !fin.eof(),当读到文件结束时,fin.eof()并不会立即返回1,所以最后一个字符就多读了一次,如何避免这种情况发生,需要加上一个条件:int main(){ uchar c; ifstream in("2.txt"); while (!in.eof()) { in >> c; if (in.fail()) { break;
2015-05-16 18:23:25 3013
原创 环境变量
环境变量是提供了一个标识,在该标识下对应一个路径,一些应用程序会通过该标识去识别路径下的应用程序执行文件。我们通过 我的电脑(右击)-》属性-》高级-》环境变量 来设置环境变量 Path,多个路径用‘;’隔开。通过命令行下 path命令可以查看当前已经设置的环境变量。
2015-05-16 18:16:33 549
原创 如何将一个C++代码工程转换为matlab的mex文件直接调用呢
1)首先我们要写一个接口函数mexFunction(),这个接口函数就是类似C++的main函数,它是入口函数,传递参数给我们的C++函数。#include "mex.h" //mx函数,mex函数用到的头文件#include "exp.h"//调用函数用到的头文件void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxAr
2015-05-16 17:27:10 2530
原创 如何使用matlab来批处理文件图片格式
1)首先第一步,建立一个matlab脚本文件,要设置处理图片文件的路径,我们使用dir()函数来获取某一个文件夹下的jpg格式的图片的结构体信息 X*X struct array with fields: name date bytes isdir datenum2)使用matlab读写图片的函数imread()、imwrite()读写
2015-05-16 17:24:10 858
原创 MATLAB函数库
Matlab函数库Matlab函数库2006-12-01 10:06:03.0A aabs 绝对值、模、字符的ASCII码值acos 反余弦acosh 反双曲余弦acot 反余切acoth 反双曲余切acsc 反余割acsch 反双曲余割align 启动图形对象几何位置排列工具all 所有元素非零为真angle 相角ans 表达式计算结果的缺省变
2015-05-16 17:23:22 1435
原创 将图像分割成以每个像素为中心32*32的区域
DIRPARAM.ORIGIN_IMAGE_DIR = 'E:\background\images';DIRPARAM.RESULT_IMAGE_DIR = 'E:\background\cropimage';fprintf('make a new dir for every image named by imagename\n');im_dir = dir([DIRPARAM.ORIG
2015-05-16 16:03:58 1656 1
基于zlib库实现简单文件及文件夹的压缩解压缩功能
2022-04-28
threadPool.rar
2021-04-12
shell脚本学习.md
2020-11-20
msdn gdi+文档.pdf
2020-08-31
GetSoftInfo.rar
2020-07-09
zstd解压缩库.rar
2020-06-15
QNX_Neutrino_RTOS_C_Library_Reference.pdf
2019-11-20
libtorrent1.2dll 32 and 64.rar
2019-07-05
软件注册码生成以及验证方法(duilib界面)
2018-09-11
基于tensorflow实现猫狗识别代码(CNN)
2018-08-17
卷积神经网络MNIST代码及测试数据
2018-07-13
CEdit控件重写类CEditList,输入自动提示匹配内容
2018-05-25
duilib与MFC结合做的软件界面DEMO
2018-01-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人