dmndxld

码不停题

随笔分类 -  力扣学习

1 2 下一页

入门学徒
102. Binary Tree Level Order Traversal
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3 阅读全文

posted @ 2019-05-19 20:56 imyourterminal 阅读(113) 评论(0) 推荐(0)

1041. Robot Bounded In Circle
摘要:On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions: "G": go straight 1 unit; "L 阅读全文

posted @ 2019-05-15 21:44 imyourterminal 阅读(201) 评论(0) 推荐(0)

144. Binary Tree Preorder Traversal
摘要:Given a binary tree, return the preorder traversal of its nodes' values. Example: My idea:ricursion OTHERS:iretator 阅读全文

posted @ 2019-05-13 21:46 imyourterminal 阅读(161) 评论(0) 推荐(0)

283. Move Zeroes
摘要:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Note: M 阅读全文

posted @ 2019-05-12 18:05 imyourterminal 阅读(155) 评论(0) 推荐(0)

26. Remove Duplicates from Sorted Array
摘要:Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra spa 阅读全文

posted @ 2019-05-12 12:08 imyourterminal 阅读(189) 评论(0) 推荐(0)

151. Reverse Words in a String
摘要:Given an input string, reverse the string word by word. My idea:删除左右两边空格,转换成数组,再把中间空格给改了,再专成字符串,用快慢指针找到单词放进去,很麻烦,所以效果不好。 执行用时 : 92 ms, 在Reverse Words 阅读全文

posted @ 2019-05-11 17:36 imyourterminal 阅读(206) 评论(0) 推荐(0)

119. Pascal's Triangle II
摘要:Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note that the row index starts from 0. Follow up: Could 阅读全文

posted @ 2019-05-11 16:11 imyourterminal 阅读(146) 评论(0) 推荐(0)

189. Rotate Array
摘要:Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Note: Try to come up as many solutions as you can, there 阅读全文

posted @ 2019-05-08 21:22 imyourterminal 阅读(103) 评论(0) 推荐(0)

209. Minimum Size Subarray Sum
摘要:Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't 阅读全文

posted @ 2019-05-07 21:17 imyourterminal 阅读(108) 评论(0) 推荐(0)

485. Max Consecutive Ones
摘要:Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: My idea:for循环遍历,最后退出循环的时候也要判断,因为为1的时候我不能去给max赋值 那用双指针怎么做呢,参考 阅读全文

posted @ 2019-05-07 19:42 imyourterminal 阅读(108) 评论(0) 推荐(0)

27. Remove Element
摘要:Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another ar 阅读全文

posted @ 2019-05-07 18:06 imyourterminal 阅读(141) 评论(0) 推荐(0)

167. Two Sum II - Input array is sorted
摘要:Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function 阅读全文

posted @ 2019-05-06 22:00 imyourterminal 阅读(112) 评论(0) 推荐(0)

561. Array Partition I
摘要:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of 阅读全文

posted @ 2019-05-06 20:52 imyourterminal 阅读(113) 评论(0) 推荐(0)

344. Reverse String
摘要:Question: Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another 阅读全文

posted @ 2019-05-06 20:27 imyourterminal 阅读(168) 评论(0) 推荐(0)

14. 最长公共前缀
摘要:题目: 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例 1: 说明: 所有输入只包含小写字母 a-z 。 思路:既然给我的是字符串数组,那我要比较的就不是两个元素了,所以考虑把这些元素的元素都一个一个取出来,放进空字符串里面,然后用字符串的count方 阅读全文

posted @ 2019-05-06 11:59 imyourterminal 阅读(142) 评论(0) 推荐(0)

实现strStr()
摘要:题目:给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回 -1。 示例: 说明: 当 needle 是空字符串时,我们应当返回什么值呢?这是一个在面试中很好的问题。 对于本题而言, 阅读全文

posted @ 2019-05-06 10:59 imyourterminal 阅读(305) 评论(0) 推荐(0)

二进制求和
摘要:题目: 给定两个二进制字符串,返回他们的和(用二进制表示)。 输入为非空字符串且只包含数字 1 和 0。 示例 1: 思路:我反正佛了我自己的思路。。先把字符串转列表,然后加0对其,因为我不会从高位加所以就颠倒相加得结果,结果是列表,再颠倒转字符串就行了。。。。我去。。这个不熟python可真难受 阅读全文

posted @ 2019-05-06 01:14 imyourterminal 阅读(323) 评论(0) 推荐(0)

记第一次参加leecode竞赛
摘要:虽然仅仅只是完成了第一小题,但是这毕竟是第一次嘛 第二题是跟树有关的,没看明白,先留坑 给出二叉搜索树的根节点,该二叉树的节点值各不相同,修改二叉树,使每个节点 node 的新值等于原树中大于或等于 node.val 的值之和。 提醒一下,二叉搜索树满足下列约束条件: 节点的左子树仅包含键小于节点键 阅读全文

posted @ 2019-05-05 23:18 imyourterminal 阅读(183) 评论(0) 推荐(0)

杨辉三角
摘要:给定一个非负整数 numRows,生成杨辉三角的前 numRows 行。 思路:先分情况。然后迭代。。以后一定用一下递归 示例: 执行用时 : 92 ms, 在Pascal's Triangle的Python3提交中击败了6.40% 的用户 内存消耗 : 13 MB, 在Pascal's Trian 阅读全文

posted @ 2019-05-05 12:03 imyourterminal 阅读(126) 评论(0) 推荐(0)

螺旋矩阵
摘要:题目:给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返回矩阵中的所有元素。 实例: 思路:想用一个对应矩阵全至0,然后右下左上这样寻路,走过至为1,结果遇到了越界的情况,尴尬的是我还不会处理这种情况,先留个坑。。 参考一下别人的思路,还是厉害。。。 这里说一下我早 阅读全文

posted @ 2019-05-04 19:40 imyourterminal 阅读(228) 评论(0) 推荐(0)

1 2 下一页

导航