06 2018 档案

摘要:描述Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.分析从前往后扫描,用一个临时变量记录分段数字。如果当前比前一个大,说明这一段的值应该 阅读全文
posted @ 2018-06-18 22:14 昵称真难想 阅读(284) 评论(0) 推荐(0)
摘要:描述Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.分析无代码 看到有用递归的方法(转载) 阅读全文
posted @ 2018-06-18 17:14 昵称真难想 阅读(117) 评论(0) 推荐(0)
摘要:描述Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the 阅读全文
posted @ 2018-06-17 17:57 昵称真难想 阅读(104) 评论(0) 推荐(0)
摘要:描述Write a function to find the longest common prefix string amongst an array of strings.分析从位置 0 开始,对每一个位置比较所有字符串,直到遇到一个不匹配。 代码 阅读全文
posted @ 2018-06-16 16:15 昵称真难想 阅读(106) 评论(0) 推荐(0)
摘要:描述Implement wildcard paern matching with support for '?' and '*'.'?' Matches any single character. '*' Matches any sequence of characters (including 阅读全文
posted @ 2018-06-16 00:33 昵称真难想 阅读(196) 评论(0) 推荐(0)
摘要:描述Implement regular expression matching with support for '.' and '*'.'.' Matches any single character. '*' Matches zero or more of the preceding eleme 阅读全文
posted @ 2018-06-13 22:39 昵称真难想 阅读(171) 评论(0) 推荐(0)
摘要:描述Given a string S, find the longest palindromic substring in S. You may assume that the maximumlength of S is 1000, and there exists one unique longe 阅读全文
posted @ 2018-06-13 22:08 昵称真难想 阅读(145) 评论(0) 推荐(0)
摘要:描述Given two binary strings, return their sum (also a binary string).For example, a = "11" b = "1" Return ”100” 分析 无 代码 方法二 阅读全文
posted @ 2018-06-13 17:10 昵称真难想
摘要:描述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 阅读全文
posted @ 2018-06-13 11:29 昵称真难想 阅读(153) 评论(0) 推荐(0)
摘要:KMP算法 字符串的快速匹配 阅读全文
posted @ 2018-06-13 00:09 昵称真难想
摘要:描述Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.分析暴力算法的复杂度是 O(m ∗ n),代 阅读全文
posted @ 2018-06-11 23:59 昵称真难想 阅读(343) 评论(0) 推荐(0)
摘要:描述Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoringcases.For example,”A man, a plan, a canal: Pan 阅读全文
posted @ 2018-06-11 22:49 昵称真难想 阅读(148) 评论(0) 推荐(0)
摘要:描述Given an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a linear runtime 阅读全文
posted @ 2018-06-11 17:33 昵称真难想
摘要:Single Number描述Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear 阅读全文
posted @ 2018-06-11 17:04 昵称真难想
摘要:描述Follow up for ”Search in Rotated Sorted Array”: What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a functi 阅读全文
posted @ 2018-06-11 15:56 昵称真难想
摘要:描述Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target va 阅读全文
posted @ 2018-06-11 15:46 昵称真难想
摘要:描述Given a sorted array, remove the duplicates in place such that each element appear onlyonce and return the new length.Do not allocate extra space fo 阅读全文
posted @ 2018-06-11 15:22 昵称真难想
摘要:Remove Duplicates from Sorted Array II描述Follow up for ”Remove Duplicates”: What if duplicates are allowed at most twice?For example, Given sorted arra 阅读全文
posted @ 2018-06-11 15:00 昵称真难想
摘要:描述The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total n 阅读全文
posted @ 2018-06-10 23:44 昵称真难想
摘要:两排序好的数组,找中位数 描述There are two sorted arrays A and B of size m and n respectively. Find the median of the two sortedarrays. The overall run time complex 阅读全文
posted @ 2018-06-10 15:19 昵称真难想
摘要:(转载) 按位与运算符(&) 参加运算的两个数据,按二进制位进行“与”运算。 运算规则:0&0=0; 0&1=0; 1&0=0; 1&1=1; 即:两位同时为“1”,结果才为“1”,否则为0 例如:3&5 即 0000 0011 & 0000 0101 = 0000 0001 因此,3&5的值得1。 阅读全文
posted @ 2018-06-10 15:01 昵称真难想
摘要:类似 输入eeffffgghhhhh输出efghefghfhfhh 时间有限,所以暴力解题了 代码如下: 阅读全文
posted @ 2018-06-09 21:59 昵称真难想 阅读(346) 评论(0) 推荐(0)
摘要:第一行表示有多少个数n第二行开始依次是1到n个数,一个数一行输出描述:输出一行,表示最少跳跃的次数。示例1输入72321215输出3 说明 7表示接下来要输入7个正整数,从2开始。数字本身代表可以跳跃的最大步长,此时有2种跳法,为2-2-2-5和2-3-2-5都为3步 阅读全文
posted @ 2018-06-09 21:42 昵称真难想 阅读(282) 评论(0) 推荐(0)
摘要:用了一种自创的比较简洁的方式来创建链表 阅读全文
posted @ 2018-06-09 21:29 昵称真难想
摘要:描述Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2.After rem 阅读全文
posted @ 2018-06-09 21:20 昵称真难想
摘要:描述Given a list, rotate the list to the right by k places, where k is non-negative.For example: Given 1->2->3->4->5->nullptr and k = 2, return 4->5->1- 阅读全文
posted @ 2018-06-09 21:11 昵称真难想
摘要:断断续续用了半年的时间把LeetCode刷完了,之前复习了数据结构与算法。将刷题与复习数据结构结合起来会更有效果。总之不是为了刷题而刷题,而是为了巩固和补充一部分知识。 LeetCode真的是一个很好的题库,可惜没有早些时候发现它。现在有些公司的算法笔试题五花八门,但万变不离其宗。刷完LeetCod 阅读全文
posted @ 2018-06-09 21:03 昵称真难想
摘要:描述 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 阅读全文
posted @ 2018-06-09 20:11 昵称真难想
摘要:描述Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then 阅读全文
posted @ 2018-06-09 20:01 昵称真难想 阅读(226) 评论(0) 推荐(0)