摘要: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return[1,3,3,1]. Note:Could you optimize your algorithm to use 阅读全文
posted @ 2016-09-01 14:26 googlemeoften 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 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 example, given the fo 阅读全文
posted @ 2016-09-01 14:08 googlemeoften 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning 阅读全文
posted @ 2016-09-01 13:15 googlemeoften 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 题目:给定一个字符串s,你可以从中删除一些字符,使得剩下的串是一个回文串。如何删除才能使得回文串最长呢?输出需要删除的字符个数。 思路:该题目可以先将字符串s倒序然后求倒序字符串与原来字符串的最长公共子序列(动态规划:dp[i][j] 表示的是Str1[0...i] 与 Str2[0...j] 的最 阅读全文
posted @ 2016-09-01 11:11 googlemeoften 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 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 re 阅读全文
posted @ 2016-08-31 16:48 googlemeoften 阅读(138) 评论(0) 推荐(0) 编辑
摘要: There are N gas stations along a circular route, where the amount of gas at station i isgas[i]. You have a car with an unlimited gas tank and it costs 阅读全文
posted @ 2016-08-31 16:41 googlemeoften 阅读(165) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Follow up:Can you solve it without using extra space? 给 阅读全文
posted @ 2016-08-31 15:20 googlemeoften 阅读(180) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For 阅读全文
posted @ 2016-08-31 14:54 googlemeoften 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree{1,#,2,3}, return[3,2,1]. Note: Recursive solut 阅读全文
posted @ 2016-08-29 18:07 googlemeoften 阅读(291) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list using insertion sort 创建一个新的链表,将旧链表的节点插入到正确的位置 阅读全文
posted @ 2016-08-29 17:23 googlemeoften 阅读(197) 评论(0) 推荐(0) 编辑