自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 [Leetcode]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 t...

2019-08-01 10:54:03 96

原创 Leetcode: 反转32-bit整数

真的没意思的一道题,刚开始还想用stack做,后来只能感叹python的强大,直接反转字符串,核心代码就是[::-1]class Solution: def reverse(self, x: int) -> int: if x > -10 and x < 10: return x sign = 1 ...

2019-05-21 11:05:11 379

原创 Leetcode: Zigzag conversion

没啥技术含量的一道题。。。刚开始想用数学的方法找规律的,2n-2什么的,后来觉得python的一些特性挺适合这道题的class Solution: def convert(self, s: str, numRows: int) -> str: if (numRows >= len(s) or numRows==1): return s...

2019-05-18 19:21:01 89

原创 Leetcode 找最大回文子字符串

用动态规划做。思路很简单,maintain一个dp的二维数组,里面记录dp[i][j]的状态:true就是从I到j 的子字符串是palindrome。分base和recursive case:base就是substring的长度是1或2,直接比较s[i]和s[j],recursive:如果s[i]等于s[j] 并且s[i+1][j-1]也是palindrome,则设 dp[i][j]为true。...

2019-05-17 16:45:28 132

原创 Leetcode 找最长不重复子字符串

Given a string, find the length of the longest substring without repeating characters.Example 1:Input: “abcabcbb”Output: 3Explanation: The answer is “abc”, with the length of 3.Example 2:Input: ...

2019-05-17 00:59:00 249

原创 Leetcode 用链表相加两个数

Leetcode 用链表相加两个数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 nu...

2019-05-17 00:38:08 206

空空如也

空空如也

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

TA关注的人

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