- 博客(29)
- 资源 (1)
- 收藏
- 关注
原创 两数相除——不允许使用高级运算
两数相除——不允许使用高级运算Divide Two Integers实现两整数相除,不允许使用乘法、除法、和取余运算。如果结果溢出(int范围为-2147483648 ~ 2147483647),返回MAX_INT题目原文:Divide two integers without using multiplication, division and mod operator.If it is
2017-08-07 11:29:21
396
原创 移除数组中的重复元素
移除数组中的重复元素Remove Duplicates from Sorted Array给定一个数组,移除数组中的重复元素,返回新数组的长度,不允许开辟新的数组空间,只能在原数组内存中完成。题目原文:Given a sorted array, remove the duplicates in place such that each element appear only once and
2017-08-01 16:34:24
674
1
原创 k组倒置链表节点
k组倒置链表节点Reverse Nodes in k-Group给定一个链表,每k个倒置其节点,返回新链表的头部,不允许使用额外的内存,只能在原有链表节点基础上进行操作。题目原文:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a pos
2017-07-31 18:00:57
341
原创 成对交换链表节点
成对交换链表节点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 retu
2017-07-25 18:51:19
890
原创 合并n个已排序的链表
合并n个已排序的链表Merge k Sorted Lists合并n个已排序的链表,新链表中的每个节点必须是来自输入的原链表的节点(即不能构造新的节点),返回新链表的头部。Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.example 1input:
2017-07-19 16:43:06
401
原创 构造n个成对括号
构造n个成对括号Generate Parentheses给出一个整数n,实现一个函数生成n对小括号,n对小括号的左右括弧顺序不限,但应该闭合。Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.example 1For example, gi
2017-07-19 09:30:34
424
原创 合并两个已排序的链表
合并两个已排序的链表Valid Parentheses合并两个已排序的链表,新链表中的每个节点必须是来自输入的两个链表的节点(即不能构造新的节点),返回新链表的头部。Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the node
2017-06-30 14:22:49
287
原创 验证大小中括号是否成对闭合匹配
验证大小中括号是否成对闭合匹配Valid Parentheses验证大小中括号是否成对闭合匹配。Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.The brackets must close in the c
2017-06-30 11:55:50
1585
原创 移除链表倒数第n个元素
移除链表倒数第n个元素Remove Nth Node From End of List给定一个链表,移除倒数第n个元素,返回链表头部。Given a linked list, remove the nth node from the end of list and return its head.Note: Given n will always be valid. Try to do t
2017-06-30 11:54:52
266
原创 四元组相加获得target
四元组相加获得target4Sum给定一个数组,选择四个元素相加,结果为target,找出所有符合的四元组。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
2017-06-30 11:41:44
385
原创 九宫格键盘输入
九宫格键盘输入Letter Combinations of a Phone Number给定一个数字字符串,返回数字可能代表的所有可能的字母组合。数字到字母的映射(就像九宫格电话按钮一样)如下图。 Given a digit string, return all possible letter combinations that the number could represent.A map
2017-06-28 14:20:44
7779
原创 三元组相加获得结果最接近target
三元组相加获得结果最接近target3SumClosest给定一个数组,选择三个元素相加,结果必须为所有三元组中最接近target的值,返回这个三元组的和Given an array S of n integers, find three integers in S such that the sum is closest to a given number: target.Return th
2017-06-27 11:40:39
466
原创 三元组相加获得target
三元组相加获得target3Sum给定一个数组,选择三个元素相加,结果为target,找出所有符合的三元组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
2017-06-27 11:32:14
474
原创 字符串数组最长公共前缀
字符串数组最长公共前缀Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.example 1input: ['asdqowi','asdb', 'asdmnc']output: 'asd'思路i从0开始自增,判断每个字符串 i 位置
2017-06-23 16:39:04
4812
原创 罗马数字转换成阿拉伯数字
罗马数字转换成阿拉伯数字Roman to integerGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.example 1input: CCCLXXXIXoutput: 389思路dict存储单个罗马字母代表的阿拉伯数字初始
2017-06-23 12:46:44
1356
原创 阿拉伯数字转换成罗马数字
阿拉伯数字转换成罗马数字Integer to RomanGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.example 1input: CCCLXXXIXoutput: 389思路用表记录关键的罗马数字和阿拉伯数字,将输入循环除
2017-06-23 12:14:37
654
原创 容器最大盛水量
容器最大盛水量Container With Most WaterGiven n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai).n vertical lines are drawn such that the two endpoints of line i is at
2017-06-22 21:42:06
709
原创 反转整数
反转整数Reverse Integerexample 1input: x = 123, return 321example 2input: x = -123, return -321note: * The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed
2017-06-20 01:24:14
284
原创 从数组中寻找和的相加数
从数组中寻找和的相加数Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may
2017-06-20 00:47:25
525
原创 两个链表数字相加
两个链表数字相加Add Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the t
2017-06-19 17:08:54
425
原创 手动实现.*正则表达式匹配函数
手动实现简单正则表达式匹配函数regular expression matching'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input string (not partial).Some exa
2017-06-18 00:33:48
1440
原创 合并两棵二叉树(7 lines)
合并两棵二叉树Merge Two Binary TreesGiven two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge
2017-06-13 10:31:15
868
原创 不使用任何额外变量判断回文数字(6行代码)
不使用任何额外变量判断回文数字Palindrome NumberDetermine whether an integer is a palindrome. Do this without extra space.Notes: any negative number is not palindrome.Example 1:Input: 1221Output: TrueExample 2:
2017-06-12 23:24:17
345
原创 实现atoi函数(string转integer)
实现atoi函数(string转integer)String to Integer (atoi)Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. Notes: It is intended for this problem to be speci
2017-06-12 22:56:47
614
原创 查找字符串最长回文
查找字符串最长回文Longest Palindromic SubstringGiven a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: "bab"Note: “a
2017-06-04 13:26:08
674
原创 查询两个数组的中位数
查询两个数组的中位数Median of Two Sorted ArraysThere are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log
2017-06-04 11:50:20
368
原创 寻找最长不重复子串
寻找最长不重复子串Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the
2017-06-04 11:42:21
360
原创 手写体数字识别例子
mnist是一个大型的手写体数字数据库,广泛应用于机器学习领域的训练和测试。mnist对每张图都已经进行尺寸归一化,固定尺寸28像素x28像素。 下面开始手写体的简单例子测试caffe的安装情况。(注:未编译安装caffe请移步到我的博客:Ubuntu14.04下深度学习平台caffe的安装 文章)1.下载mnist数据集 mnist部分数据集可以在caffe根目录下data/mnist下用
2017-03-18 00:08:43
3741
原创 Ubuntu14.04下深度学习框架Caffe的搭建
随着机器学习中神经网络技术的发展,衍生出深度学习技术,前段google公司风头一时无两的“阿尔法狗”就是深度学习的产物。而Caffe就是一款优秀的易于学习的深度学习框架。Caffe本身由c++写成,支持Java和Python接口。而本篇文章就是Caffe的入门篇之一,平台的搭建。 首先,推荐在linux下进行Caffe的学习。本文使用的是Ubuntu的14.04版本。由于使用GPU加速所需的环境比
2017-03-17 23:17:01
1605
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人