自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 18. 4Sum LeetCode题解

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: The solution

2017-06-01 11:12:12 344

原创 17. Letter Combinations of a Phone Number LeetCode题解

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.Input:Di

2017-05-22 11:40:17 440

原创 16. 3Sum Closest LeetCode题解

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-05-21 10:08:23 373

原创 15. 3Sum LeetCode题解

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 contain

2017-05-20 11:56:16 417

原创 14. Longest Common Prefix LeetCode题解

Write a function to find the longest common prefix string amongst an array of strings.Subscribe to see which companies asked this question.题意:写一个函数用来寻找字符串数组的最长公共前缀。题解:从字符串第一个字符

2017-05-19 09:37:09 251

原创 13. Roman to Integer LeetCode题解

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question.题意:给定一个罗马数字,将其转换为整数。输入数

2017-05-18 09:29:43 304

原创 12. Integer to Roman LeetCode题解

Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question.题意:给定一个整数,将其转换为罗马数字。输入范

2017-05-16 09:01:24 247

原创 11. Container With Most Water LeetCode题解

Given 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 (i, ai) and (i, 0). Fin

2017-05-15 16:23:52 300

原创 10. Regular Expression Matching LeetCode题解

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

2017-05-14 09:42:46 332

原创 9. Palindrome Number LeetCode题解

Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Subscribe to see which companies asked this question.题意:判断一个整数是否回文,不要使用额外空间;题解:

2017-05-13 08:51:00 266

原创 8. String to Integer (atoi) LeetCode题解

Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca

2017-05-12 09:50:20 296

原创 7. Reverse Integer LeetCode题解

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321翻转整数中的数字click to show spoilers.Note:The input is assumed to be a 32-bit signed integer. You

2017-05-11 09:31:47 215

原创 6. ZigZag Conversion LeetCode题解

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)字符串"PAYPALISHIRING" 写成

2017-05-10 10:35:32 327

原创 5. Longest Palindromic Substring LeetCode题解

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.题意:给定一个字符串s,找出其中最长的回文子串,假定字符串最长为1000Example:Input: "babad"Output: "ba

2017-05-09 11:10:32 309

原创 4. Median of Two Sorted Arrays LeetCode题解

题目描述:There 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 (m+n)).题目大意:已排

2017-05-07 22:54:37 224

原创 3. Longest Substring Without Repeating Characters LeetCode题解

题目描述:Given a string, find the length of the longest substring without repeating characters.题目大意:给定一个字符串,找到无重复字符的最长子串。Examples:Given "abcabcbb", the answer is "abc", which the len

2017-05-06 18:25:05 243

原创 2. Add Two Numbers LeetCode题解

题目描述: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

2017-05-04 16:58:13 272

原创 1. Two Sum LeetCode(0ms 极致探索)

题目描述Given 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 not use

2017-05-04 00:24:26 571

原创 C#串口通信 [实战] (读取激光雷达数据,生成图像)

效果展示话不多说,先上激光雷达图像效果图:激光雷达用的是雷达大叔的二手货,基本上长这个样子:操作步骤一、读取串口数据要生成激光雷达图像,首先就是获取串口数据了,所以第一步就是读取串口数据:由于是帮朋友调试,开始朋友给了错误的SDK,导致调试半天没有任何结果,索性用串口助手查看一下这货返回些什么数据:

2017-03-09 17:17:09 10907 10

原创 CF Round #348 Div. 2 A. Little Artem and Present B. Little Artem and Grasshopper C. Little Artem and

今天起开始刷CF,不知道能坚持多久,希望不要放弃,编程这东西一放就忘。关于解题,能用语言描述的东西就不画图了,下面进入正题。A. Little Artem and Present题意:小A有一些石子,想作为礼物送给小M。小M不在意送的礼物是否为贵重,而在意送礼物的次数。如果是送石子,小M还记得上次送了几个石子,所以为了讨好小M, 需要保证送礼物次数尽可能多并且每次送的数量和

2016-04-27 00:24:41 455

原创 322. Coin Change

代码如下:// CPPclass Solution {public: int coinChange(vector& coins, int amount) { if (amount == 0) { return 0; } // 初始化数组为 0,并将已有钱数置为 1 // initialized

2016-03-14 23:52:11 770 1

原创 319. Bulb Switcher

// CPPclass Solution {public: int bulbSwitch(int n) { int result = 0; for (int i = 1; i * i <= n; ++i) { ++result; } return result; }};// JAVA

2015-12-23 13:13:33 3127 1

原创 DP总结

2015-09-11 17:57:45 439

原创 binarySearch二分查找总结

2015-09-04 20:00:25 1540

原创 LeetCode string类题目总结

2015-09-01 10:46:09 1374 1

原创 面向对象程序设计三个基本特征(C++)

2015-08-14 22:04:59 4375

原创 Stack总结

2015-08-10 00:41:01 553

原创 List总结

————————————————————————————————————————————————————————————————————————————==========================================================================================================================

2015-08-06 22:55:55 475

原创 《C++入门经典》读书笔记 第11章 创建自己的数据类型

11.1 结构类型是程序中的一个新的数据类型,实际上是不同数据类型的数据项的一个指定聚合。11.2 结构对象是带有成员的对象,这些对象在默认情况下可以公开访问。结构可以有数据成员和函数成员。11.3 typedef语句不创建新的类型,只是为已有的类型定义一个别名。11.4如果结构成员是类类型,就不能通过直接赋值的方式来初始化结构,原因是类类型的对象只能通过调用一

2014-12-15 20:46:01 602

原创 《C++入门经典》读书笔记+习题解答 第10章 程序文件和预处理器指令

读书笔记:10.1 头文件与源文件的区别?   (1).cpp文件主要包含确定程序做什么的代码,它们由函数定义组成;   (2).h文件包含函数声明、内联函数定义,枚举和自己的类型定义,以及预处理指令,尽量避免在头文件中定义函数。10.2 程序中的每个实体都只能有一个定义:   (1)在转换单元(它是添加了所有包含都文件内容的.cpp文件)中,每个不是局部块作用域的变量

2014-12-05 00:48:50 881

原创 《C++入门经典》读书笔记+习题解答 第9章 函数

读书笔记:9.1 函数的重载(使用同一函数名的不同函数)需要满足以下条件之一:  (1)每个函数的参数个数不同;  (2)参数个数相同,但至少有一对对应参数的类型不同;  Tips:重载函数不能仅通过返回值类型来区分。9.2 编译器对重载函数的使用:  (1)参数没有对应匹配的,自动转向更高一级的类型(例如float -> double);  (2)参数没有对应

2014-12-02 23:21:44 735

原创 Tsinghua MOOC 列车调度(Train)

描述某列车调度站的铁道联接结构如图所示。其中,A为入口,B为出口,S为中转盲端。所有铁道均为单轨单向式:列车行驶的方向只能是从A到S,再从S到B;另外,不允许超车。因为车厢可在S中驻留,所以它们从B端驶出的次序,可能与从A端驶入的次序不同。不过S的容量有限,同时驻留的车厢不得超过m节。设某列车由编号依次为{1, 2, ..., n}的n节车厢组成。调度员希望知道,按照以上交通规则,

2014-12-02 18:22:40 3370

原创 Cocos2d-x 3.1.1环境配置

零基础,开始学习cocos2d-x。首先需要配置环境

2014-11-22 12:41:17 625

原创 Tsinghua MOOC 祖玛(Zuma)

描述祖玛是一款曾经风靡全球的游戏,其玩法是:在一条轨道上初始排列着若干个彩色珠子,其中任意三个相邻的珠子不会完全同色。此后,你可以发射珠子到轨道上并加入原有序列中。一旦有三个或更多同色的珠子变成相邻,它们就会立即消失。这类消除现象可能会连锁式发生,其间你将暂时不能发射珠子。开发商最近准备为玩家写一个游戏过程的回放工具。他们已经在游戏内完成了过程记录的功能,而回放功能的实现则

2014-11-19 16:42:53 5983 5

原创 Tsinghua MOOC 范围查询(Range)

数轴上有n个点,对于任一闭区间 [a, b],试计算落在其内的点数。输入第一行包括两个整数:点的总数n,查询的次数m。第二行包含n个数,为各个点的坐标。以下m行,各包含两个整数:查询区间的左、右边界a和b。输出对每次查询,输出落在闭区间[a, b]内点的个数。输入样例5 21 3 7 9 114 67 12 输出

2014-11-19 15:47:21 2335

原创 poj2593 Max Sequence

同样是DP动态规划的题目,解题思路和poj2479也是一样的。从左到右计算并保存每个节点(包含该节点)以前所有子范围中和的最大值,再从右向左计算每个节点(包含该节点)的子范围中和的最大值,并同时计算与前半部分和,更新此最大值,直到最后输出。代码如下:

2014-11-15 11:50:53 636

原创 poj2479 Maximum sum

刚开始刷OJ,看大神对POJ上问题的分类,从动态规划的问题开始。对动态规划的理解不是很深刻,但是基本思路是分步解决问题,相同的子问题不重复计算,从而提升算法的效率。对于这道题,我的思路是先从左到右,计算并存储每个节点(包括该节点)以前子范围的最大值。再从右向左,计算每个节点(包括该节点)以后的子范围的最大值,此时不必再存储该值,而直接计算该值与前半部分之和,并不断更新和的最大值。代码如下:

2014-11-15 11:40:01 457

poj2479 Maximum sum

poj2479代码 Maximum sum 对于这道题,我的思路是先从左到右,计算并存储每个节点

2014-11-30

空空如也

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

TA关注的人

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