自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(82)
  • 资源 (9)
  • 收藏
  • 关注

原创 基于单链表的快速排序

struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};void qsortList(ListNode* begin, ListNode* end){ if(begin==NULL||begin==end) return; ListNode* inde

2013-10-31 09:55:58 1125

转载 深入理解C++的动态绑定和静态绑定

为了支持c++的多态性,才用了动态绑定和静态绑定。理解他们的区别有助于更好的理解多态性,以及在编程的过程中避免犯错误。需要理解四个名词:1、对象的静态类型:对象在声明时采用的类型。是在编译期确定的。2、对象的动态类型:目前所指对象的类型。是在运行期决定的。对象的动态类型可以更改,但是静态类型无法更改。关于对象的静态类型和动态类型,看一个示例:[cpp] vi

2013-10-30 22:38:34 1468

转载 [C/C++]static关键字用法总结

Static关键字用法总结  static关键字是C, C++中都存在的关键字。static从字面理解,是“静态的“的 意思,与此相对应的,应该是“动态的“。static的作用主要有以下3个:1、扩展生存期;2、限制作用域;3、唯一性; 1、扩展生存期这一点主要是针对普通局部变量和static局部变量来说的。声明为static的局部变量的生存期不再是当前作用

2013-10-30 22:31:20 1294

原创 Leetcode: Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. * struct ListNode { * int val;

2013-10-29 22:55:33 3176 1

原创 Leetcode: Valid Number

Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguo

2013-10-29 11:48:16 6497 2

原创 Leetocde: Palindrome Partitioning II

Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",Return

2013-10-28 23:41:31 6672 1

原创 Leetcode: Palindrome Partitioning

Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","b"],

2013-10-28 22:07:16 4213 2

原创 Leetcode: Word Ladder II

Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be changed at a timeEach intermediate word must exi

2013-10-28 20:54:34 8092

原创 Leetcode: Word Ladder

Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word m

2013-10-28 12:19:23 4386

原创 Leetcode: Multiply Strings

Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.方法一:模拟手算乘法string addTwoString(strin

2013-10-27 23:34:49 7917 2

原创 一个单例模式引发的血案

今天下午去面试,二面面了有一个半小时,最后面试官说,你写个代码吧,你一定要注意各种语法啊,考虑效率啊,blabla...你写个单例模式吧。然后我就开始写了。。。然后写了下面的代码给面试官,然后说,多线程加锁的忘了具体是什么了。。。class Singleton {private: static Singleton * volatile pInstance; Singleton

2013-10-26 21:06:14 1600

原创 Leetcode: Median of Two Sorted Arrays

There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).思路:核心是将原问题转变成一个寻找第k小数的问题(假设两个

2013-10-26 00:24:00 3707

原创 Leetcode: Word Break II

Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens =

2013-10-25 23:02:00 3282

原创 Leetcode: Substring with Concatenation of All Words

You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without an

2013-10-25 16:26:48 5098 1

原创 Leetcode: 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.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.

2013-10-25 11:45:16 1808

原创 Leetcode: 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 vertically n

2013-10-24 23:31:01 2276

原创 Leetcode: Sudoku Solver

Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudoku

2013-10-24 21:57:27 3432

原创 Leetcode: Valid Sudoku

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially filled sudo

2013-10-24 17:46:13 10505 1

原创 Leetcode: Candy

There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on

2013-10-24 12:29:25 2675 1

原创 Leetcode: Clone Graph

Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each

2013-10-24 12:00:24 1725

原创 Leetcode: Gas Station

There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its

2013-10-23 22:13:21 2067

原创 一道面试题

一个数组arr,长度为N,N小于10^8,里面数字的范围是1~N,求每个数字出现的次数面试时我首先想到的是:方法1:因为数字的范围是10^8,所以如果用int表示出现的次数足够了,我们用bitmap,当然不是用一位来表示出现的次数,而是用一个int表示一个数出现的次数。空间复杂度:O(n)时间复杂度:O(n)面试官说:这个空间复杂度太高啊,有没有空间O(1)

2013-10-23 11:35:23 1246

原创 Leetcode: N-Queens II

Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.方法一:我们继续用N-Queens的方法,Time Limit Exceeded,Last executed input:11

2013-10-19 23:02:20 3418

原创 Leetcode: N-Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.Eac

2013-10-19 22:50:17 4189

原创 Leetcode: Divide Two Integers

Divide two integers without using multiplication, division and mod operator.用减法:Time Limit Exceededint divide(int dividend, int divisor) { // Note: The Solution object is instantiate

2013-10-17 19:02:41 8578 2

原创 Leetcode: Permutation Sequence

The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""312

2013-10-17 17:56:05 12299

原创 Leetcode: Implement strStr()

Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.Time Limit Exceededchar *strStr(char *haystack, char *

2013-10-17 15:09:12 2523

原创 Leetcode: Rotate List

Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL./** * Definition f

2013-10-17 11:33:34 1371

原创 平方数的约数个数

有100个灯(初始状态全部关闭),现要进行1000轮switch操作(如果原来是关则打开,如果原来开则关闭)。在第X轮操作中,若100能够整除X,则进行switch操作。那么这1000轮操作结束后,开着的灯是那些呢?按题意的代码:void func1(){ bool light[101]={0}; for(int i = 1; i <= 1000; i++)//x

2013-10-16 22:44:10 2722

原创 Leetcode: Text Justification

Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You should pack your words in a greedy approach; that is,

2013-10-15 16:26:17 2734

原创 Leetcode: Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover t

2013-10-15 00:21:55 6328

原创 Leetcode: Regular Expression Matching

Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st

2013-10-14 23:09:15 20310 4

原创 数组连续子序列的最大和&最大积

int MaxProduct(int* arr, int len){ int dp1 = arr[0]; int dp2 = arr[0]; int largest = arr[0]; for (int i = 1; i < len; ++i) { int tmp1 = dp1*arr[i]; int tmp2 = dp2*arr

2013-10-14 21:52:27 1291

转载 C++ Boost

Boost准标准库boost是一个准标准库,相当于STL的延续和扩充,它的设计理念和STL比较接近,都是利用泛型让复用达到最大化。不过对比STL,boost更加实用。STL集中在算法部分,而boost包含了不少工具类,可以完成比较具体的工作。     boost主要包含一下几个大类:字符串及文本处理、容器、迭代子(Iterator)、算法、函数对象和高阶编程、泛型编程、模板元编

2013-10-11 20:19:13 7777

转载 求和问题总结(leetcode 2Sum, 3Sum, 4Sum, K Sum)

前言:做过leetcode的人都知道, 里面有2sum, 3sum(closest), 4sum等问题, 这些也是面试里面经典的问题, 考察是否能够合理利用排序这个性质, 一步一步得到高效的算法. 经过总结, 本人觉得这些问题都可以使用一个通用的K sum求和问题加以概括消化, 这里我们先直接给出K Sum的问题描述和算法(递归解法), 然后将这个一般性的方法套用到具体的K, 比如leet

2013-10-09 00:15:19 21312 6

原创 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 exactly

2013-10-09 00:11:54 2841

原创 Leetcode: 4Sum

Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:

2013-10-08 12:51:59 7932 1

原创 Leetcode: 3Sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a trip

2013-10-08 12:45:26 2693 1

原创 Leetcode: Sqrt(x)

Implement int sqrt(int x).Compute and return the square root of x.二分法:这道题一看到函数的定义int sqrt(int x)都是int就高兴了,直接二分吧。但是要注意,即使用long long都TM越界,还要用unsigned long long。最后返回值还要再检查一下。int sqrt(int x) {

2013-10-07 21:56:53 17289 9

原创 Leetcode: Recover Binary Search Tree

Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devis

2013-10-07 21:27:05 2329

数据挖掘引论-6.clustering.pdf

中国科学院 数据挖掘引论 刘莹 课件

2011-09-19

数据挖掘引论-5.classification.pdf

中国科学院 数据挖掘引论 刘莹 课件

2011-09-19

数据挖掘引论-4.ARM.pdf

中国科学院 数据挖掘引论 刘莹 课件

2011-09-19

数据挖掘引论-3.Preprocessing_upload.pdf

中国科学院 数据挖掘引论 刘莹 课件

2011-09-19

数据挖掘引论-2.Data_Warehouse.pdf

中国科学院 数据挖掘引论 课件 刘莹

2011-09-19

数据挖掘引论-1.Intro.pdf

中国科学院 数据挖掘引论 课件 刘莹

2011-09-19

Android获取运营商代码

Android获取运营商代码 IMSI MCC MNC MIN

2011-08-16

自动售货机的设计与实现

数字逻辑课程设计 自动售货机 VHDL

2009-08-31

数据结构 树和二叉树 ppt

我们老师的课件 ,是学数据结构的好东西,老师可是花了很多的心血啊, 树和二叉树。

2009-05-03

空空如也

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

TA关注的人

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