自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LeetCode 15. 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: The solution set must not

2017-05-09 19:11:46 333

原创 LeetCode 46. Permutations(同47,只是不包含重复数字)

Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]

2017-04-19 22:49:07 289

原创 LeetCode 47. Permutations II(生成不同的组合-dfs)

Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[ [1,1,2], [1,2,1], [2,1

2017-04-19 22:42:00 280

原创 LeetCode 48. Rotate Image 数组90度翻转(要求空间复杂度)

题目:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?我的方法:假设一个3维数组      0    1    2    3 0

2017-04-19 21:47:49 275

原创 LeetCode 49. Group Anagrams 找相同的字母组成的字符串

题目:Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]

2017-04-19 20:10:56 331

原创 LeetCode 38. 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

2017-04-19 19:28:05 224

原创 LeetCode 21. Merge Two Sorted Lists 两个有序列表合成一个

题目Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Subscribe to see which companies asked this

2017-04-19 17:50:27 370

原创 LeetCode 20. Valid Parentheses 判断()[]{}是否完整

Total Accepted: 189650Total Submissions: 576679Difficulty: EasyContributor: LeetCodeGiven a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input stri

2017-04-19 17:07:17 162

原创 LeetCode 14. Longest Common Prefix 找字符串数组最长相同前缀

题目:Write a function to find the longest common prefix string amongst an array of strings.Subscribe to see which companies asked this question.public class Solution { public Strin

2017-04-19 14:49:40 267

原创 LeetCode 35. Search Insert Position 二分查找

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.

2017-04-19 12:44:51 183

原创 LeetCode 13. Roman to Integer 罗马数字转整数

题目Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.按照说明书写代码:public class Solution {// 即Ⅰ(1)、X(10)、C(100)、M(1000)、V(5)、L(50)、D(50

2017-04-19 12:11:14 170

原创 并查集(Union-Find)算法理解

问题出自Algroithm一书,理解后整理一部分原书详细内容参考http://blog.csdn.net/dm_vincent/article/details/7655764一篇个人理解:1.Quick-Find 算法:存储的是数字对应的组号,如果组号相同则判断连通,存在的问题是,每一次输入pair后需要遍历更新整个数组2.Quick-Union算法:存储的是该

2017-04-19 10:59:45 219

原创 LeetCode 50. Pow(x, n) x的n的次方

Implement pow(x, n).Subscribe to see which companies asked this question.public class Solution { public double myPow(double x, int n) { if(n==0) return 1; double mid = myPow

2017-04-13 22:57:29 243

原创 LeetCode 300.Longest Increasing Subsequence 在一维数组中找最长序列(好题)

题目Given an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 101]

2017-04-13 02:45:09 276

原创 LeetCode 329. Longest Increasing Path in a Matrix 在二维数组中寻找最长递增序列

题目:Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move

2017-04-13 00:33:03 776

原创 京东机试-分堆

分堆A时间限制:C/C++语言 1000MS;其他语言 3000MS内存限制:C/C++语言 65536KB;其他语言 589824KB题目描述:小明得到了n个石头,他想把这些石头分成若干堆,每堆至少有一个石头。他把这些石堆排在一条直线上,他希望任意相邻两堆的石头数都不一样。小明最后的得分为石头数大于等于k的石堆数,问他最多能得多少分。严格地,小明把n个石头分成了m堆,每堆个数

2017-04-07 23:27:24 516

原创 网易机试-工作安排

现在有n位工程师和6项工作(编号为0至5),现在给出每个人能够胜任的工作序号表(用一个字符串表示,比如:045,表示某位工程师能够胜任0号,4号,5号工作)。现在需要进行工作安排,每位工程师只能被安排到自己能够胜任的工作当中去,两位工程师不能安排到同一项工作当中去。如果两种工作安排中有一个人被安排在的工作序号不一样就被视为不同的工作安排,现在需要计算出有多少种不同工作安排计划。 输入描述:

2017-04-01 17:04:20 1235

原创 LeetCode 9. Palindrome Number 判断是否为回文数

Determine whether an integer is a palindrome. Do this without extra space.题目解释:判断一个数是否为回文数,不能使用额外的空间注意:1.负数不能是回文数  2.如果转化为字符串进行处理就利用了额外的空间(If you are thinking of converting the integer to stri

2017-04-01 11:37:54 243

原创 LeetCode 7. Reverse Integer 整数反转

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321题目解释:将整数进行翻转,需要注意几个点:1.如果末尾是0怎么办,10反转就是12.带有正负号,-123反转是-3213.整数越界, 1534236469 反转 9646324351 超

2017-04-01 01:45:04 465

原创 LeetCode 2. Add Two Numbers 链表加和问题

You 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 two numbers and return i

2017-04-01 01:08:53 278

原创 算法-整数拆分

正整数n可以拆成若干个正整数之和,考虑拆分方案的个数。输入 5 输出 5首先证明:g(i,j)= g(i,j-1)+ g(i-j,j)(1)     如果j>i,则g(i,j)=g(i,i);如果j=i, 则g(i,j)=g(i,j-1)+1;如果ji的划分中包含j,除j以外其余分解数的和为i-j,此情况下g(i,j)=g(i-j,j)i的划分中不包含j

2017-03-29 13:04:18 2670 1

原创 算法-爬梯子

题目:假如你正在爬一个梯子,梯子有n层,每次可以爬1层或2层,求有多少种不同的爬梯子方式。输入:2      输出:5输入:5      输出:8import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner in = new Scanner

2017-03-29 12:24:18 1085

原创 POJ-3984 迷宫问题 广度优先搜索

问题链接:http://poj.org/problem?id=3984思路参考:http://blog.csdn.net/raphealguo/article/details/7523411 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1,

2017-03-27 00:29:39 299

原创 网易机试-赶去公司

终于到周末啦!小易走在市区的街道上准备找朋友聚会,突然服务器发来警报,小易需要立即回公司修复这个紧急bug。假设市区是一个无限大的区域,每条街道假设坐标是(X,Y),小易当前在(0,0)街道,办公室在(gx,gy)街道上。小易周围有多个出租车打车点,小易赶去办公室有两种选择,一种就是走路去公司,另外一种就是走到一个出租车打车点,然后从打车点的位置坐出租车去公司。每次移动到相邻的街道(横向或者纵向)

2017-03-26 18:06:39 792

原创 Java核心技术学习整理(二)

1.面向对象程序开发(OOP)是由程序组成的,每个对象包含对用户公开的特定功能和用户隐藏的实现部分2.依赖(uses-a):一个类的方法操作另一个类的对象    聚合(has-a):类A的对象包括类B的对象    继承(is-a): 类A拓展于类B,包含一些类B没有的功能3.面向对象程序设计:首先从设计类开始,然后往每个类中添加方法4.对象与对象变量的区

2015-10-08 16:18:04 553

原创 Java核心技术学习整理(一)

1.final表示常量,只能被赋值一次,习惯上常量名全大写;static final表示类常量,可以被类的其他方法使用;public static final 可以被其他类使用2.Math.sqrt()用于开根号计算 Math.pow(x,a)用于幂的计算,相当于X的a次方3.强制类型转换是以截断小数部分将浮点数转换为整数,(int)Math.round(x)来进行四舍五入

2015-10-07 20:44:48 303

原创 二叉树三种序列的两种转化

已经大四了。保研完成,是时候应该给自己放松一下!但是心里久久不能平静,因为找工作的人讨论的东西我会的并不多。真的现在出去找工作不知道会找到什么样的,所以说还是好好读研吧!最近发现自己的数据结构——算法+语法已经烂到极致,ccf200分,真是一年不如一年,我也不能再骗自己了,拿起数据结构+算法要从头再学一遍。。百度三面提到了前序遍历,中序遍历以及后序遍历的相互转化,自己学习学习并练习一下!#

2015-09-24 18:35:03 983

原创 c++ SQL Server ADO串连

第一次玩CSDN,一个大学本科生,到了快毕业的年纪,真不知道是应该样样涉猎还是一心钻研。怎么说,走一步是一步吧。今天找了做了C++ 和 SQLServer 连接的方式,在网上寻找很多方法并不适用,今天自己改着改着弄出来了,留作纪念!#include #include#include#include using namespace std;#import "c:\program fil

2015-06-07 20:48:09 516

空空如也

空空如也

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

TA关注的人

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