摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,... 阅读全文
posted @ 2015-03-15 00:29 desperadox 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文
posted @ 2015-03-15 00:23 desperadox 阅读(103) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return theinordertraversal of its nodes' values.和preorder是一样的,把左子节点一直压入到栈中,直到没有左子节点为止,然后出栈访问,存储右子节点。 1 vector inorderTraversal(Tr... 阅读全文
posted @ 2015-03-15 00:08 desperadox 阅读(115) 评论(0) 推荐(0) 编辑
摘要: Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set toNULL.Initially, all next ... 阅读全文
posted @ 2015-03-14 23:39 desperadox 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return thepreordertraversal of its nodes' values.简单题,递归和迭代都可以解。 1 class Solution { 2 public: 3 vector preorderTraversal(TreeN... 阅读全文
posted @ 2015-03-14 23:18 desperadox 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 最近一直在回顾linear regression model和logistic regression model,但对其中的一些问题都很疑惑不解,知道我看到广义线性模型即Generalized Linear Model后才恍然大悟原来这些模型是这样推导的,在这里与诸位分享一下,具体更多细节可以参... 阅读全文
posted @ 2015-03-13 22:51 desperadox 阅读(3260) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it.简单题,只要知道快慢指针这个技巧就很容易解了。 1 class Solution { 2 public: 3 bool hasCycle(ListNode *head) { 4 ... 阅读全文
posted @ 2015-03-12 23:51 desperadox 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Given a column title as appear in an Excel sheet, return its corresponding column number.本质上是一个进制转换问题。1 class Solution {2 public:3 int titleToNumb... 阅读全文
posted @ 2015-03-12 23:45 desperadox 阅读(97) 评论(0) 推荐(0) 编辑
摘要: Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?简单动态规划。判别每个左右子树各有多少种情况,然后相乘就可以了,而且是BST,注意这条件就可以解了。它的状态转移方程为: ... 阅读全文
posted @ 2015-03-12 23:28 desperadox 阅读(94) 评论(0) 推荐(0) 编辑
摘要: Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an... 阅读全文
posted @ 2015-03-12 22:24 desperadox 阅读(97) 评论(0) 推荐(0) 编辑