描述
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999
分析比Integer to Roman简单多了,是加法规则还是减法规则很好判断
...
描述
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
分析要考虑罗马数字的加法规则和减法规则,要写对还是有一定技巧的,下面是一个精
...
描述
Validate if a given string is numeric.
Some examples:“0” => true“ 0.1 “ => true“abc” => false“1 a” => false“2e10” => trueNote: It is
...
描述
Write a function to find the longest common prefix string amongst an array of strings.
分析简单题,但容易想复杂。第一反应是用trie树,可以做,但实现较复杂。其实只要按位置依次比对每一个字符串,直到有不相
...
描述
Implement wildcard pattern matching with support for ‘?’ and ‘*‘.
‘?’ Matches any single character.‘*‘ Matches any sequence of characters (includin
...
描述
Implement regular expression matching with support for ‘.’ and ‘*‘.
‘.’ Matches any single character.‘*‘ Matches zero or more of the preceding elem
...
描述
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lon
...
描述
Given two binary strings, return their sum (also a binary string).
For example,a = “11”b = “1”Return “100”.
分析简单题。
代码Python12345678910111213141516
...
描述
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 bel
...
描述
Implement strStr().
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
分析查找子字符串,暴力搜索时间复杂度O(
...
描述
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,“A man, a plan, a canal:
...
描述
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.
get(key) - Get
...
描述
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes’ values.
...
描述
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.
Note: Do not modify the linked list.
Follow up:Can
...
描述
Given a linked list, determine if it has a cycle in it.
Follow up:Can you solve it without using extra space?
分析经典题,使用两指针,一个每次走一步,另一个走两步,如果两指针相遇,则
...