leetcode-java
wuxiaosi808
这个作者很懒,什么都没留下…
展开
-
LeetCode系列:best time to buy and sell stock
由于最近在准备找工作,会刷写LeetCode的经典题目。因为最近编码能力实在不强,有些题目需要借鉴其他博主或者大神的解题思路,如有冒犯,请多原谅。如有错误,请指正,定会虚心接受并改正,不胜感激!题目描述:Say you have an array for which the i th element is the price of a given stock on day i.If you were原创 2017-07-20 11:33:23 · 284 阅读 · 0 评论 -
Leetcode: populating-next-right-pointers-in-each-node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node. I原创 2017-07-31 15:20:36 · 357 阅读 · 0 评论 -
LeetCode:distinct-subsequence
给出字符串S和字符串T,计算S的不同的子序列中T出现的个数。子序列字符串是原始字符串通过删除一些(或零个)产生的一个新的字符串,并且对剩下的字符的相对位置没有影响。(比如,“ACE”是“ABCDE”的子序列字符串,而“AEC”不是)。样例给出S = "rabbbit", T = "rabbit"返回 3参考牛客网“蓝月亮”同学的代码public class So原创 2017-07-31 15:42:13 · 332 阅读 · 0 评论 -
leetcode:path-sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree andsum原创 2017-07-31 15:58:38 · 411 阅读 · 0 评论 -
leetcode:path -sum-ii
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum = 22, 5 / \原创 2017-07-31 16:38:10 · 310 阅读 · 0 评论 -
leetcode:interleaving string
Problem: Interleaving StringGiven s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", ret转载 2017-08-06 20:49:00 · 220 阅读 · 0 评论 -
leetcode:candy
题目:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at原创 2017-08-06 20:51:32 · 281 阅读 · 0 评论 -
lettcode:二分法sqrt(x)
题目:Implementint sqrt(int x). Compute and return the square root of x. 代码如下:public class Solution { public int sqrt(int x) { if(x return x; int begin=1原创 2017-10-04 15:40:03 · 325 阅读 · 0 评论 -
单向链表每k个元素翻转一次
给出一个链表,每k个节点一组进行翻转,并返回翻转后的链表。k是一个正整数,它的值小于或等于链表的长度。如果节点总数不是k的整数倍,那么将最后剩余节点保持原有顺序。示例 :给定这个链表:1->2->3->4->5当k= 2 时,应当返回:2->1->4->3->5当k= 3 时,应当返回:3->2->...转载 2019-05-16 16:13:50 · 2051 阅读 · 0 评论