随笔分类 -  leetcode

摘要:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文
posted @ 2015-04-06 14:52 HaruHaru 阅读(168) 评论(0) 推荐(0)
摘要:Problem:The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid ... 阅读全文
posted @ 2015-01-28 16:01 HaruHaru 阅读(191) 评论(0) 推荐(0)
摘要:Problem:Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the largest fo... 阅读全文
posted @ 2015-01-27 21:15 HaruHaru 阅读(149) 评论(0) 推荐(0)
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating,... 阅读全文
posted @ 2014-12-17 21:22 HaruHaru 阅读(222) 评论(0) 推荐(0)
摘要:Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="... 阅读全文
posted @ 2014-10-19 00:36 HaruHaru 阅读(161) 评论(0) 推荐(0)
摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity1. Naive Solution思路:直接的想法依次找出列表中的最小项串接起来。 复杂度分析:时间复杂度... 阅读全文
posted @ 2014-10-01 23:53 HaruHaru 阅读(178) 评论(0) 推荐(0)
摘要:Problem Description:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tre... 阅读全文
posted @ 2014-06-29 19:39 HaruHaru 阅读(184) 评论(0) 推荐(0)
摘要:Problem Description:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node do... 阅读全文
posted @ 2014-06-29 15:46 HaruHaru 阅读(117) 评论(0) 推荐(0)
摘要:Problem Description:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Popul... 阅读全文
posted @ 2014-06-29 15:08 HaruHaru 阅读(117) 评论(0) 推荐(0)
摘要:Problem Description:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your pr... 阅读全文
posted @ 2014-06-29 15:05 HaruHaru 阅读(117) 评论(0) 推荐(0)
摘要:Problem Description:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1... 阅读全文
posted @ 2014-06-29 15:04 HaruHaru 阅读(138) 评论(0) 推荐(0)
摘要:Problem Description:Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your alg... 阅读全文
posted @ 2014-06-29 15:03 HaruHaru 阅读(92) 评论(0) 推荐(0)
摘要:Problem Description:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For ex... 阅读全文
posted @ 2014-06-29 15:02 HaruHaru 阅读(199) 评论(0) 推荐(0)
摘要:Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most... 阅读全文
posted @ 2014-06-29 15:01 HaruHaru 阅读(102) 评论(0) 推荐(0)
摘要:Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit... 阅读全文
posted @ 2014-06-29 15:00 HaruHaru 阅读(128) 评论(0) 推荐(0)
摘要:Problem Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit... 阅读全文
posted @ 2014-06-29 14:58 HaruHaru 阅读(141) 评论(0) 推荐(0)
摘要:Problem Description:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below bina... 阅读全文
posted @ 2014-06-29 14:56 HaruHaru 阅读(131) 评论(0) 推荐(0)
摘要:Problem Description:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a... 阅读全文
posted @ 2014-06-29 14:55 HaruHaru 阅读(126) 评论(0) 推荐(0)
摘要:Problem Description:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Onl... 阅读全文
posted @ 2014-06-29 14:54 HaruHaru 阅读(190) 评论(0) 推荐(0)
摘要:Problem Description:Given two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one l... 阅读全文
posted @ 2014-06-29 14:52 HaruHaru 阅读(169) 评论(0) 推荐(0)