上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页
摘要: 假设有一组数字三角形, 由一个数字可以到下一层的左或右,求一条最短的路径. 使用动态规划 自顶向下考虑,如果 因此有 而 初始化为 自底向上考虑, 的最短路径应当包含 或`dp[i+1][j+1] dp[i][j] = min(dp[i 1][j], dp[i 1][j 1]) + mat[i][j 阅读全文
posted @ 2017-08-03 04:18 lepeCoder 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 题目 Given a non empty string s and a dictionary wordDict containing a list of non empty words, determine if s can be segmented into a space separated s 阅读全文
posted @ 2017-08-01 14:18 lepeCoder 阅读(317) 评论(0) 推荐(0) 编辑
摘要: 题目 Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 分析 判断链表是否有环,采用快慢指针,如果相遇则表示有环 AC代码 阅读全文
posted @ 2017-07-31 21:03 lepeCoder 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 题目 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up: Can 阅读全文
posted @ 2017-07-31 20:26 lepeCoder 阅读(256) 评论(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. 阅读全文
posted @ 2017-07-31 18:04 lepeCoder 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 原题 Given a binary tree, return the preorder traversal of its nodes' values. 分析 对二叉树进行先序遍历,即根节点 左子树 右子树 代码: 递归: 递归代码十分简单,建立一个vector作为返回的结果,现将根节点push进去, 阅读全文
posted @ 2017-07-30 22:15 lepeCoder 阅读(327) 评论(0) 推荐(0) 编辑
摘要: __描述:__ Given a binary tree, return the postorder traversal of its nodes' values. 直接递归,按照 左子树 右子树 头结点的顺序 AC代码: 阅读全文
posted @ 2017-07-30 21:21 lepeCoder 阅读(275) 评论(0) 推荐(0) 编辑
摘要: __描述:__ Sort a linked list using insertion sort. 使用插入排序对一个链表进行排序 普通的插入排序,时间复杂度O(n^2) 阅读全文
posted @ 2017-07-30 13:12 lepeCoder 阅读(269) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list in O(n log n) time using constant space complexity. 阅读全文
posted @ 2017-07-30 03:00 lepeCoder 阅读(363) 评论(0) 推荐(0) 编辑
摘要: sublime lincense for linux Sublime Text 3.x (after Build 3133)—– BEGIN LICENSE —–TwitterInc200 User LicenseEA7E-8900071D77F72E 390CDD93 4DCBA022 FAF60 阅读全文
posted @ 2017-07-26 14:58 lepeCoder 阅读(708) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页