自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 收藏
  • 关注

原创 leetcode--40. Combination Sum II

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combina

2017-10-15 18:52:54 249

原创 leetcode--39. Combination Sum

Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen

2017-10-15 18:19:03 237

转载 LeetCode总结,二分法一般性总结

一,学习别人的总结与讲解本部分的参考见末尾,本部分文字是在其基础上的二度总结(节约时间和精力)。1,典型的二分法算法:当数据量很大适宜采用该方法。采用二分法查找时,数据需是排好序的。 基本思想:假设数据是按升序排序的,对于给定值key,从序列的中间位置k开始比较,如果当前位置arr[k]值等于key,则查找成功;若key小于当前位置值arr[k],则在数

2017-10-12 16:42:08 331

原创 leetcode--34. Search for a Range

Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the targ

2017-10-12 16:21:32 226

原创 C语言基础--测试程序中实现对FPS的控制

const int FRAMES_PER_SECOND = 25;const int SKIP_TICKS = 1000 / FRAMES_PER_SECOND;DWORD next_game_tick = GetTickCount();// GetTickCount() returns the current number of milliseconds// that have ela

2017-10-11 21:41:04 1592

原创 leetcode--33. Search in Rotated Sorted Array

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in

2017-10-11 21:12:45 228

原创 leetcode--24. Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y

2017-10-01 09:48:06 291

原创 leetcode--22. Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()

2017-10-01 08:35:24 301

原创 leetcode--19. 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, th

2017-09-30 22:30:02 184

原创 leetcode--18. 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.这道题目最主要的关注点:

2017-09-30 16:19:36 221

原创 leetcode--17. Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.利用back

2017-09-29 14:51:58 218

原创 leetcode--16. 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

2017-09-28 21:41:10 222

原创 leetcode--8. String to Integer (atoi)

将string转化为int,要求包括:The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional

2017-09-28 17:03:13 204

原创 利用udev实现设备hotplug通知

何为udev?从linux2.6起,引入了udev作为device manager。udev运行在user space,user可以通过udev rules管理设备。udev提供了一个动态设备目录,目录中仅包含连接到系统中的设备的节点。创建的设备文件在/dev目录下。早期linux利用/sbin/hotplug监听设备插拔,hotplug在2.5之后被移除,直接由udev利用netlink

2017-09-28 12:49:52 1297

原创 leetcode--169.Major Element

L169:找出出现次数大于数组长度一半的数。 方一:Moore voting利用其余数组加起来都没有这个数字多的特性。记录一个max,记录一个target,凡是不等于target,将max-1。如果max==0,更换target和max。 方二:Hashtable,最方便。 方三:分治算法。Divide

2017-09-23 17:13:16 347

原创 leetcode--189.Rotate

L189:将一个数组里的数,向右移动 k位。(shift)。要求多种方法。 坑:k可能大于len,所以需要取余。 方案1:将数组复制,依次填入新的位置。新的位置为(i+k)%n 方案2:将数组reverse。将数组第0-k-1位reverse将数租第k-len-1位reverse 方案3:

2017-09-23 17:12:15 259

原创 leetcode--532.K-DiffPairsInAnArray

L532:在一个数组中,找到绝对值为k的两个数,统计共有多少对这样的pairs。Tips:HashTable 坑:1、empty check2、k是否大于03、{1,3}和{3,1}是同一种组合 解决3:如果k==0,那么当相同的数过来的时候,需要二次统计,例如[1,1,1,1],但是仅进行1次。如果k!=0,

2017-09-23 17:10:15 233

原创 leetcode--Contain Duplicate

L217:ContainDuplicates如果数组含有相同的数,返回trueHashtable  L219:数组含有相同数,且两个下标的绝对值不大于k坑:1、如果检测出下标大于k,记得更新下标。例如[1,0,1,1]。更新下标的操作可以与建表合并。hashmap[nums[i]] = i;  //这个操作既可以更新表,又可以

2017-09-23 17:09:11 259

原创 leetcode--Remove Elements

Two Pointers L26:RemoveDuplicatesFromSortedArray有序数组,将重复的数删除(放在数组尾端),并返回新数组长度。Tips:For循环,用i遍历数组。只有nums[i]!=nums[i-1]的时候,进行交换操作,其他时候无操作。 L27:Remove Element将某一个

2017-09-23 17:07:47 290

原创 leetcode--414.Third Maximam

L414:找出一组数中,第三大的数。Tips:将max1,max2,max3均设为-1.如果max1为-1 或 新来的数一直等于max1,则不做任何变化。如果max2为-1 或 新来的数一直等于max2,则更新max1和max2.如果max3为-1 或 新来的数大于max3,更新max1,max2,max3.

2017-09-23 17:05:37 279

原创 leetcode--66.Plus One

L66:将一个整数用一个数组表示,将这个整数+1。Tips:问题点在于是否进位。若进行到某一下标i,nums[i]vectorplusOne(vector& digits) {        int len = digits.size();        for(int i = len-1; i>=0; i--){            if(digits[

2017-09-23 17:04:12 251

原创 leetcode--PascalTriangle

L118:建立一个杨辉三角 L119:将杨慧三角的第n行取出

2017-09-23 16:57:03 182

原创 leetcode--BinarySearch

L35:常规二分查找 L278:常规二分查找 L374:常规二分查找 L367:perfect number判断一个数n是否是某个整数的平方方1:N-1-3-5-7-9-…… == 0 ? True:false 方2:X=nWhile x*x>n 则更新x=(x+n/x)/2

2017-09-23 16:55:34 305

原创 leetcode--1、15、167 2Sum、3sum

L1:无序数组找出相加为target的两个数特征:无序、无重复、每个元素只能用一次、有且只有一组答案Tag:O(n) hashmap解:Step1:hashmap中,key存储number,value存储index。Step2:在hashmap的key中寻找 target-number。只需常数时间。Step3:一边建表一边比较。如果找到

2017-09-23 16:52:48 247

原创 leetcode--547. Friend Circles

There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, the

2017-09-18 19:42:41 463

原创 C语言基础--利用json文件load config信息

如果依赖json-c库jason文件格式:{ "achievement" : [ "ach1", "ach2", "ach3" ],  "age" : 23,  "name" : "Tsybius",  "partner" : {  "partner_age" : 21,  "partner_name" : "Galatea",  "partner_se

2017-09-17 10:44:40 613

原创 C语言基础--读文件

从一个文件中读取数据到一块buffer中 fp = fopen(file_path, "r"); if(fp == NULL) return -1; fseek(fp, 0, SEEK_END); unsigned int length = ftell(fp); rewind(fp); if(!(buf = malloc(length)

2017-09-15 21:14:56 446

空空如也

空空如也

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

TA关注的人

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