![](https://img-blog.csdnimg.cn/2019091813595558.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
LeetCode
路漫漫其修远兮
AStupidHorse
这个作者很懒,什么都没留下…
展开
-
走格子和求区间内素数平均值
最近参加了一个线上笔试,记录下里面两道题grid path 从一个田字格(2X2)的左上角出发,只允许向右或向下移动,恰好有6条路径。则对于20X15的,从左上角出发到右下角的路径共有多少条?思路:画图很直观。这里先把图转换为二维矩阵,则2X2的图对应的矩阵为(3,3),grid=[[0,0,0],[0,0,0],[0,0,0]]。由于只能向右或者向下,所以第一行以及第一列的路径都是1。即grid[0][x]=0,x in range(0,n+1),grid[y][0]=0,y in range(0原创 2020-09-18 10:31:04 · 306 阅读 · 0 评论 -
leetcode-20. 有效的括号
descriptionGiven a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same...转载 2020-02-07 23:08:58 · 135 阅读 · 0 评论 -
leetcode-13. 罗马数字转整数
descriptionRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2020-02-07 23:01:06 · 113 阅读 · 0 评论 -
leetcode-09. 回文数
leetcode T09descriptionDetermine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: -121...原创 2020-02-07 22:27:48 · 92 阅读 · 0 评论 -
leetcode-07. 整数反转
leetcode T07descriptionGiven a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:As...原创 2020-02-07 22:23:11 · 102 阅读 · 0 评论 -
leetcode-01. 两数之和
leetcode T01descriptionGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and y...原创 2020-02-07 22:18:13 · 106 阅读 · 0 评论 -
leetcode-14. 最长公共前缀
leetcode T14descriptionWrite a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.Example 1:Input: [“flower”,“fl...原创 2020-02-07 22:12:49 · 95 阅读 · 0 评论