LeetCode/Easy
文章平均质量分 81
tsfissure
这...不填可以不...
展开
-
[LeetCode]:ZigZag Conversion
今天开始写下LeetCode.然后按顺序搬到这里和github吧,旨在更短,更效率,同时要便于理解. [ZigZag Conversion] The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to disp原创 2015-11-04 13:38:41 · 361 阅读 · 0 评论 -
[LeetCode]Add Binary&Climbing Stairs&Remove Duplicates from Sorted List
今天写得蛮快的,来个三连发。Add Binary Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100".题意:二进制加法. 解法:把两个串都倒过来(低位先加).然后模拟一下就好了.注意最后也要进位就好.原创 2015-11-18 13:33:55 · 396 阅读 · 0 评论 -
[LeetCode]Length of Last Word&Plus One
发现还早,并没有睡意,再看了一眼后面的Easy,发现很快,so,写了吧,为了节约能源,把两题合在一起Length of Last Word Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the str原创 2015-11-17 13:31:12 · 336 阅读 · 0 评论 -
[LeetCode] Count and Say
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.原创 2015-11-17 13:13:59 · 299 阅读 · 0 评论 -
[LeetCode] Valid Sudoku
Valid Sudoku Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’.原创 2015-11-16 19:59:52 · 343 阅读 · 0 评论 -
[LeetCode] Implement strStr()[字符串hash]
题目:Implement strStr() Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.题意:实现strStr,给两个串A和B,总B是不是A的子串,如果是,返回第一个子串的起始位置,原创 2015-11-14 13:43:51 · 400 阅读 · 0 评论 -
[LeetCode] Remove Duplicates from Sorted Array & Remove Element
Remove Duplicates from Sorted ArrayRemove Element发现这两题性质差不多,于是就一起写了吧.Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place such that each element appear only once a原创 2015-11-12 13:24:52 · 319 阅读 · 0 评论 -
[LeetCode] Merge Two Sorted Lists
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.解法:原创 2015-11-11 13:13:43 · 336 阅读 · 0 评论 -
[LeetCode] Valid Parentheses
Valid ParenthesesLeetCode20 Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. The brackets must close in the correct order, “原创 2015-11-10 13:29:38 · 303 阅读 · 0 评论 -
[LeetCode] Remove Nth Node From End of List
Remove Nth Node From End of List写完最长前缀,看了一眼下一个easy,发现是个几行代码的题。so,写了吧。 题目: Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked原创 2015-11-09 13:46:38 · 311 阅读 · 0 评论 -
[LeetCode] Longest Common Prefix
[LeetCode] Longest Common Prefix上一个easy的是那个罗马数字转int。我还百度了一下规则,感觉太恶心了这种模拟题,跳过好了..今天写了最长公共前缀 Write a function to find the longest common prefix string amongst an array of strings. *解法:如果为空的话,肯定是返回空串了。如原创 2015-11-09 13:20:12 · 283 阅读 · 0 评论 -
[LeetCode]:String to Integer (atoi)
按Easy顺序刷..刚开始就遇见了面试最常见的一个题了,去年我记得也遇到过,当初答得发水的,今天都又被坑了好几发. Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, plea原创 2015-11-06 13:34:12 · 319 阅读 · 0 评论 -
[LeetCode]:Reverse Integer(Only两类解法)
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 题目大意比较简单,就是把一个整数反转,这个比较容易,但需要注意的是,返转过后,有可能溢出,所以这题的坑就是在溢出这里。 解法一:先把result定义成long long直接翻转,最原创 2015-11-05 13:13:25 · 470 阅读 · 0 评论 -
[LeetCode]Easy合集I
Merge Sorted Array 题意:给长度为m数组1和长度为n的数组2,都是有序的,要求合成一个数组而且是有序的。(数组1的长度大于等于n+m) 解法:倒着过来存比较好处理,枚举数组1的值x,把数组2大于等于x的值加到数组1的后面,然后再把x加到后面。 Code Same Tree 题意:给两棵二叉数,判断是不是完全一样的. 解法:暴力即可,递归下去看节点如果都为空返回true原创 2015-12-27 18:39:05 · 510 阅读 · 0 评论