描述 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. 分析要考虑罗马数字的加法规则和减法规则,要写对还是有一定技巧的,下面是一个精 ...
阅读全文 »

描述 Write a function to find the longest common prefix string amongst an array of strings. 分析简单题,但容易想复杂。第一反应是用trie树,可以做,但实现较复杂。其实只要按位置依次比对每一个字符串,直到有不相 ...
阅读全文 »

描述 Given two binary strings, return their sum (also a binary string). For example,a = “11”b = “1”Return “100”. 分析简单题。 代码Python12345678910111213141516 ...
阅读全文 »

描述 Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 分析经典题,使用两指针,一个每次走一步,另一个走两步,如果两指针相遇,则 ...
阅读全文 »