2014年4月12日

【LeetCode练习题】Reverse Words in a String

摘要: Reverse Words in a StringGiven an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Clarification:What constitutes a word?A sequence of non-space characters constitutes a word.Could the input string contain leading or t 阅读全文

posted @ 2014-04-12 21:00 Allen Blue 阅读(233) 评论(0) 推荐(0) 编辑

【LeetCode练习题】Minimum Path Sum

摘要: Minimum Path SumGiven amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:You can only move either down or right at any point in time.还是DP问题,给定一个m*n的二维数组,每一个值都是非负数。问从起点(左上角)到终点(右下角)的一条路径上所有的数加起来的和最小是多少?解题思路:参考 阅读全文

posted @ 2014-04-12 18:26 Allen Blue 阅读(374) 评论(0) 推荐(0) 编辑

【LeetCode练习题】Swap Nodes in Pairs

摘要: Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algorithm should use only constant space. You maynotmodify the values in the list, only nodes itself can be changed.相邻 阅读全文

posted @ 2014-04-12 17:16 Allen Blue 阅读(254) 评论(0) 推荐(0) 编辑

导航