自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Substring with Concatenation of All Words 滑动窗口方法 串联所有单词

# *- coding:utf-8 -*'''这道题感觉难度不小,想了好长时间,没有找到最优解法,看到大神们用一种滑动窗口方法,确实经典。滑动窗口思路: 一个窗口长度是恒定的(与一个单词长度相等),滑动一次窗口的长度,查看目前 窗口组成的word是否在words中,并要保证word只出现一次,记录状态;如果word满足条件, 就继续向右移动窗口得到新的word重

2017-07-31 20:49:21 391

原创 divided two integers

/*Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.思路: 通过移位运算来计算倍数 右移n位是2^n倍溢出条件: 1.divisor =0; 除数为0 2.dividend=INT_MIN && di

2017-07-31 11:31:41 306

原创 implement strStr

/*Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.寻找子串并返回第一次出现的位置,采用KMP算法来解决。KMP算法的核心是无回溯,利用next数字记录子串每次失配后应该从子串的何处继续匹

2017-07-30 22:34:55 294

原创 remove duplicates from sorted array

/*Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place wi

2017-07-30 19:20:21 283

原创 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.k is a positive integer and is less than or equal to the length of the linked list. If the number

2017-07-30 15:20:44 353

原创 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. You

2017-07-30 14:05:21 288

原创 generate parentheses

# -*- coding: utf-8 -*-'''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-07-29 21:23:56 368

原创 merge two list

/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode { int val; struct ListNode *next; }; #define INT_MI

2017-07-29 20:28:01 473

原创 valid parentheses

使用栈来解决:/*Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are

2017-07-29 17:18:42 336

原创 removeNthFromEnd

/*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-07-29 11:54:47 750

原创 4sum

# *- coding:utf-8 -* '''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 tar

2017-07-29 10:36:49 231

原创 letter combinations of a phone number

# -*- coding: utf-8 -*-'''lambda:匿名函数 lambda 参数 :表达式reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from lef

2017-07-28 21:37:26 258

原创 threeSumClosest

/*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 exac

2017-07-28 11:37:01 401

原创 threeSum

/** * Return an array of arrays of size *returnSize. * Note: The returned array must be malloced, assume caller calls free(). */ /* 解决思路: 先对数组进行升序排序 然后对数组进行遍历 让第一个数等于第二个数和第三个数的负数,由于数组已经有

2017-07-27 23:08:43 445

原创 longestCommonPrefix

/*Write a function to find the longest common prefix string amongst an array of strings.运行代码一直提示 runtime error ,并且在试图[]时错误,刚开始以为strs为空,判断为NULL就返回NULL,还是相同的错误!查看别人的代码,发现忽视了空字符串的情况"",空字符串是分配存储空间的,而

2017-07-27 14:07:52 388

原创 romanToInt

def romanToInt(self, s): """ Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999 :type s: str :rtype: int

2017-07-27 10:04:30 362

原创 intToRoman

# -*- coding: utf-8 -*-'''把阿拉伯数字转换为罗马数字,采用查表法罗马数字的定义:(维基百科)罗马数字共有7个,即Ⅰ(1)、Ⅴ(5)、Ⅹ(10)、Ⅼ(50)、Ⅽ(100)、Ⅾ(500)和Ⅿ(1000)。按照下述的规则可以表示任意正整数。需要注意的是罗马数字中没有“0”,与进位制无关。一般认为罗马数字只用来记数,而不作演算。重复数次:一个罗马数字重复几次,就表示这个

2017-07-27 08:53:05 531

原创 container with most water

/*Given n non-negative integers a1, a2, ..., an, where each represents a pointat coordinate (i, ai). n vertical lines are drawn such that the two endpointsof line i is at (i, ai) and (i, 0). Find t

2017-07-21 20:42:56 327

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

2017-07-21 15:54:19 573

原创 palindromeNumber

/*Determine whether an integer is a palindrome. Do this without extra space.判断一个整型数是否是回文,回文关于中心对称;如果一个整形数是回文即说明这个数的正序与反序是相等的。特殊的情况: 负数不是回文 如果整数不为零且个位数如果为零也不是回文*/#include int isPalindrome

2017-07-20 20:20:47 418

原创 stringToInteger 把字符串转换为int数

/**把一个字符串转换为整型值:* 开始位置的空格, 去掉* 符号位 ,记录* 字符串中的非法字符,直接退出并返回先前值* 转换后的结果是否越界,返回最大值或最小值**/#include #include #define INT_MAX 2147483647#define INT_MIN -2147483648int myAtoi(char*

2017-07-20 16:06:41 331

原创 reverse digits of an integer

/*Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Note:The input is assumed to be a 32-bit signed integer. Your function should

2017-07-20 11:16:06 397

原创 zigzag convert

/**zigzag covnert*/#include #include #include /*n=numRowsΔ=2n-2 1 2n-1 4n-3Δ= 2 2n-2 2n 4n

2017-07-20 09:30:20 217

原创 longestPalindrome 最长回文串

/**中心扩散法:* 如果中心字符串s是回文,那么以中心对称的字符串向左右两边扩展s1,如果左右两边* 字符关于中心对称,那么s1也是回文,遍历所有中心点,重复上述过程,找到最长回文* 子串。* 中心对称分两种情况,奇数个字符以某个字母对称;偶数个字符以中间两个字符对称* 时间复杂度:O(n^2) 空间复杂度:O(1)*/#include #in

2017-07-19 17:47:50 611

原创 findMedianSortedArrays 寻找中位数

c语言版本运行时间35ms,python版本95ms,参考http://blog.csdn.net/yutianzuijin/article/details/11499917/,博主写的特别好。/*There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the tw

2017-07-14 22:22:02 877

原创 堆排序

/**堆排序***/#include //调整算法void heapAdjust(int *arr,int i,int n){ int nChild; int tmp; for(;2*i+1<n;i=nChild) { //子节点的位置=2*(父节点的位置)+1 nChild=2*i+1; //得到子节点中较大的节点 if(nChild ’就是大顶堆

2017-07-08 21:14:58 212

原创 希尔排序

/**希尔排序:* 选取一个小于n的整数d作为第一个增量,把序列分为d组,即所有相互之间距离为d整数倍的* 元素为同一组,在各组内进行直接插入排序;取第二个增量d2(d2<d),重复上面分组与排序的* 过程,直到di=1时,即所有元素放在同一组中进行直接插入排序。*/#include void shell_sort(int *arr,int n){ int i

2017-07-08 21:14:08 188

原创 平衡二叉树

平衡二叉树:就有二叉查找树(排序树)性质、且左子树与右子树的深度差(平衡因子)的绝对值不超过1.最小不平衡子树:离插入位置最近且平衡因子绝对值大于1的节点,以该节点构成的子树为最小不平衡子树。平衡二叉树的插入:    构建平衡二叉树大体分三种情况:插入节点后,如果最小不平衡子树根节点与其孩子平衡因子同为正,则直接右旋转;如果最小不平衡子树根节点与其孩子平衡因子同为负,则直接左旋转;如果

2017-07-07 21:36:29 243

转载 哈希表(代码整理)

/**哈希表*哈希函数的构造方法: * 1.直接定址法 f(key)=a*kay+b a、b为常数* 2.数字分析法 取关键字为哈希地址* 3.平方取中法 把key平方,取中间几位* 4.折叠法* 5.除留余数法 f(key)=key%p (p<=表长)* 6.随机数法 f(key)=random(key)

2017-07-07 21:22:42 1046

原创 直插排序

#include /**直接插入排序,从数列左边开始排序,每往右移动一次,若数小于现在数列*最右边的数,则进行重新排序,先前的序列已经是有序化的。*/void insert_sort(int *arr,int n){ int i=0,j=0,temp=0; for(i=1;i<n;i++) { if(arr[i]<arr[i-1]) { temp=arr[i];

2017-07-03 11:24:41 336

原创 选择排序

#include /* * select sort 选择排序,以一个值为最小值,然后和其他值比较,遍历所有,找到最小的,交换位置 * */void select_sort(int *arr,int n){ int i=0,j=0,temp=0,min=0; for(;i<n-1;i++) { min=i; for(j=i+1;j<n;j++) {

2017-07-03 11:22:48 174

原创 快速排序

#include /**快速排序:在一个序列中随意选一个数作为基准,把大于基准的放到序列右边,*小于基准数的放到序列左边,就把大序列分成了两段,然后递归。*采用挖坑(挖掉的数temp)找数,若从最左边挖坑,先从右边找第一个小于temp的数*放到坑里,然后就出现了新坑;在从左边找第一个大于temp的数放到新坑里,继而*又出现一个新坑,一次类推,把序列分成大小两部分。*/void q

2017-07-01 15:12:48 205

基于ARM11视频采集的WiFi小车

采用ARM11(tiny6410,Linux系统可以直接采用官网的来烧写)做控制器,使用V4L2打开摄像头,opencv(2.0版本的)处理视频,其中包含人脸检测的程序(人脸检测参考的其他大神的程序),用QT写的界面程序并运行在ARM11上,通过socket通信和手机客户端通信并控制小车的运动状态。

2016-06-19

空空如也

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

TA关注的人

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