- 博客(13)
- 收藏
- 关注
原创 #448. Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array.
2017-09-12 22:37:11 228
原创 #67. Add Binary
Given two binary strings, return their sum (also a binary string). For example, a = “11” b = “1” Return “100”. 山外青山楼外楼,单说一句666;class Solution { public: string addBinary(string a, stri
2017-09-06 21:46:19 349
原创 #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-09-06 20:47:41 377
原创 #38. Count and Say
题目描述: The count-and-say sequence is the sequence of integers with the first five terms as following: 1 11 21 1211 111221 1 is read off as “one 1” or 11. 11 is read off as “two 1
2017-09-06 13:03:58 195
原创 # 28. Implement strStr()
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. class Solution { public: int strStr(string haystack, string needle
2017-09-06 09:04:00 310
原创 Valid Parentheses
题目描述: Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. The brackets must close in the correct order, “()” and “()[]{}” are a
2017-09-05 23:03:47 193
原创 #14. Longest Common Prefix
题目描述: Write a function to find the longest common prefix string amongst an array of strings. 按照Leetcode的解题指南: 寻找字符串集合的公共前缀,搜索问题,直接搜索的话有两种方法横向扫描和纵向扫描,运用算法的话可以用分治法,运用数据结构的话可以用二叉树来搜索,不断地进行剪枝操作加快搜索(不是很懂
2017-09-05 12:59:36 249
原创 #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 r
2017-09-05 09:26:35 180
原创 #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. /** * Definition for singly-linked list. * struct
2017-09-05 09:15:28 192
原创 #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. 首先理解题意,搞搞清楚罗马数字的规则。 罗马数字共有7个, 即I(1)、V(5)、X(10)、L(50)、C(100)、D(500)和M(1000)
2017-09-03 17:18:18 427
原创 #9 Palindrome Number
题目内容描述: Determine whether an integer is a palindrome. Do this without extra space. 一般判断回文数字,会把它先转换成字符串然后用头尾两个指针扫描字符串判断即可。但是题目要求不能申请多余的空间,也就是不能转换成字符串,这个难度就上来了,字符操作变成了数字操作,需要更多的技巧。首先按照回文的定义,负数由于负号的存在肯定
2017-09-03 12:27:20 204
原创 第一题 two-sum
题目描述 Problem:Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to
2017-09-02 00:00:48 225
原创 Leetcode刷题日记
第二题 Reverse Integer 从今天开始记录,学习总有个规律和过程,慢慢来,人生大部分遇到的问题都可以从前人的经验中找到答案,多看看书 题目描述: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 The input is
2017-09-01 15:55:55 713
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人