自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Continuous Subarray Sum (LeetCode Algorithm Problem)

本题主要做的是判断一组序列里面是否有这样一组连续的子序列,他们的和正好能够整除k。   我们逐步分析,一个直观的做法是暴力搜索每一个连续的字串,然后把他们相加,看看能否整除k。我们接上述Example1展开,然后我们发现:   包含第一个元素的子序列有【23,2】,【23,2,4】,【23,2,4,6】,【23,2,4,6,7】   包含第二个元素的子序列有【2,4】,【2,

2017-07-04 13:17:38 169

原创 Palindrome Number (LeetCode Algorithm Problem)

本题是判断一个整形数是不是回文,条件是空间复杂度为O(1),更直接的说,就是不能把文字转成string之后,套用Palindrome String哪一题的算法去做。 原题链接Determine whether an integer is a palindrome. Do this without extra space.我的想法很简单,先统计这个数总共有多少位,如果仅有一位,那么就直接就是回文了

2017-06-11 20:25:43 144

原创 ZigZag Conversion (LeetCode Algorithm Problem)

本题的要求是将一个普通字符串转化成二维图像下的zigzag形式,最后每行输出字符。 原题链接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

2017-06-05 17:13:28 144

原创 Swap Nodes in Pairs (LeetCode Algorithm Problems)

这道题应该是一道编程语言题,因为要解决的问题是链表的操作。原题链接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 us

2017-05-29 16:06:38 134

原创 Generate Parentheses(LeetCode Algorithm Problem)

本体是一个括号匹配的问题,但不是检查一串括号是否匹配,而是输入括号的数量,将所有匹配的括号串输出。 原题链接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-05-12 13:31:02 138

原创 3Sum

本题的要求是在一个输入列表里找出所有三个数加起来等于0的组合。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 solut

2017-05-07 16:59:46 189

原创 Letter Combinations of a Phone Number

手机电话按键这道题挺有意思的,题目要求就是将数字组合转换成在能够在手机按键上生成的字符组合。这在电视剧《越狱》中有一个桥段就是通过分析手机的字符组合来知道主角的行踪。而在九宫格输入法里面,这样的组合算法也很常用。这里写链接内容Given a digit string, return all possible letter combinations that the number could repr

2017-05-07 16:33:29 170

原创 Container With Most Water

这是一道应用题,题目讲的是,在x轴上,每一个整数点都有一条竖线,竖线的长度由一个数组height描述。那么选择两条竖线,他们和x轴共同形成一个容器(类似一个烧杯)来装水,找到能够装最多水的两条竖线。Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n ve

2017-04-24 11:37:13 117

原创 Reverse Words in a String (LeetCode medium algorithm problem)

本题的要求是将一段英文句子中的单词进行倒置。 本题链接Given an input string, reverse the string word by word.For example, Given s = “the sky is blue”, return “blue is sky the”.注意到本题的细节是将单词进行置换,而不是单纯将字符进行倒置。 做法其实并不难,就是找到单

2017-04-16 21:13:54 139

原创 Longest Substring Without Repeating Characters(Leetcode medium algorithm problem)

这周刷的题目是Longest Substring Without Repeating Characters,顾名思义,就是找字符串中最长的无重复字母的字串。原题链接Given a string, find the length of the longest substring without repeating characters.Examples:Given “abcabcbb”, the an

2017-03-27 15:20:32 147

原创 Merge k Sorted Lists (LeetCode hard algorithm problem)

本次的算法题目是Merge k Sorted Lists。 原题链接Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.题目要求是把k个已经排好序的链表重新组合成一个新的有序链表。 解题想法依然是先尝试最简单粗暴的方法,如果有问题,再在其基础上做出修

2017-03-19 17:12:19 227

原创 Regular Expression Matching (Leetcode hard algorithm problem)

经过上周的medium热身之后,这周决定选个hard的来训练一下。 这次题目为正则表达式,描述如下。原题链接‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element.The matching should cover the entire input string (not partia

2017-03-05 22:35:38 163

空空如也

空空如也

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

TA关注的人

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