自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(9)
  • 收藏
  • 关注

原创 11. Container With Most Water

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two ...

2018-03-07 23:34:02 118

原创 12. Integer to Roman

Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999. I - 1 , V - 5 ,  X - 10 ,  L - 50 ,  C - 100 , D - 500 , M -1000注意特殊数字的处理<4 直接叠加,= 4此位置+后面...

2018-03-07 23:26:20 159

转载 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. I - 1 , V - 5 ,  X - 10 ,  L - 50 ,  C - 100 , D - 500 , M -1000每次跟前面的数字比较,如果小于等于前面的数字,我们先加上当...

2018-03-07 23:18:10 309

转载 14. Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.自己的解决方案class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] ...

2018-03-07 23:04:40 103

转载 1000! 0的个数

分析:一般类似的题目都会蕴含某种规律或简便方法的阶乘末尾一个零表示一个进位,则相当于乘以10而10 是由2*5所得,在1~100当中,可以产生10的有:0 2 4 5 6 8 结尾的数字,显然2是足够的,因为4、6、8当中都含有因子2,所以都可看当是2,那么关键在于5的数量了那么该问题的实质是要求出1~100含有多少个5由特殊推广到一般的论证过程可得:1、 每隔5个,会产生一个0,比如 5, 10...

2018-03-05 23:40:05 234

原创 字符串原地逆转

不创建新的空间,将“helloword” 逆转为 “drowolleh” Pythondef reverse2(str): str = str[::-1] return strJavapackage com.company; import java.util.Scanner; public class Main { public static void reverse (...

2018-03-05 23:32:19 415

转载 6. ZigZag Conversion

特殊情况: numRows = 1 or numRows>len(s)  -  不会有字符串变形,直接返回字符串当index == 0 到达第一行位置,开始 +1当index到达末尾位置,也就是最后一行,开始-1def convert(self, s, numRows): """ :type s: str :type numRows: int ...

2018-03-05 23:10:27 106

原创 2. Add Two Numbers

//  无小数              /   精确除                 %  取余注意:给 l3 添加新节点 l3.next = ListNode(XXX)You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse...

2018-02-14 18:20:53 100

转载 3. Longest Substring Without Repeating Characters

关于答案中的三种解法 Approach 1 Brute Force  嵌套循环三次,时间复杂度高 Approach 2 Sliding Window 使用了HashSet,但是在最坏的情况下,时间复杂度O(2n) Approach 3 Sliding Window Optimized 是用了HashMap,通过键值对查找对第二种方法进行优化,减少了时间复杂度 Collection

2018-01-23 17:23:04 103

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除