03 2015 档案

摘要:Given 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 algor... 阅读全文
posted @ 2015-03-17 22:46 desperadox 阅读(136) 评论(0) 推荐(0) 编辑
摘要:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文
posted @ 2015-03-17 22:44 desperadox 阅读(188) 评论(0) 推荐(0) 编辑
摘要:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文
posted @ 2015-03-17 22:41 desperadox 阅读(167) 评论(0) 推荐(0) 编辑
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.You m... 阅读全文
posted @ 2015-03-17 22:40 desperadox 阅读(98) 评论(0) 推荐(0) 编辑
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.一直没想出原址排序... 阅读全文
posted @ 2015-03-15 23:24 desperadox 阅读(113) 评论(0) 推荐(0) 编辑
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分治是比较好而且容易想到的思路。 1 class Solution { 2 public: 3 T... 阅读全文
posted @ 2015-03-15 23:07 desperadox 阅读(104) 评论(0) 推荐(0) 编辑
摘要:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文
posted @ 2015-03-15 22:44 desperadox 阅读(213) 评论(0) 推荐(0) 编辑
摘要:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文
posted @ 2015-03-15 22:10 desperadox 阅读(110) 评论(0) 推荐(0) 编辑
摘要:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.简单题,注意逻辑顺序就好了。 1 class Solution { 2 public: 3 ListNode *d... 阅读全文
posted @ 2015-03-15 21:46 desperadox 阅读(110) 评论(0) 推荐(0) 编辑
摘要:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文
posted @ 2015-03-15 20:48 desperadox 阅读(120) 评论(0) 推荐(0) 编辑
摘要: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 阅读(105) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return theinordertraversal of its nodes' values.和preorder是一样的,把左子节点一直压入到栈中,直到没有左子节点为止,然后出栈访问,存储右子节点。 1 vector inorderTraversal(Tr... 阅读全文
posted @ 2015-03-15 00:08 desperadox 阅读(117) 评论(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 阅读(139) 评论(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 阅读(116) 评论(0) 推荐(0) 编辑
摘要:最近一直在回顾linear regression model和logistic regression model,但对其中的一些问题都很疑惑不解,知道我看到广义线性模型即Generalized Linear Model后才恍然大悟原来这些模型是这样推导的,在这里与诸位分享一下,具体更多细节可以参... 阅读全文
posted @ 2015-03-13 22:51 desperadox 阅读(3276) 评论(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 阅读(99) 评论(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 阅读(98) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文
posted @ 2015-03-12 22:17 desperadox 阅读(98) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers, every element appearstwiceexcept for one. Find that single one.非常简单的一道题。直接相异或剩下的那个数就是答案。原理是两个相等的数异或的值为0。1 class Solution {... 阅读全文
posted @ 2015-03-12 22:12 desperadox 阅读(172) 评论(0) 推荐(0) 编辑
摘要:决策树是简单的,易懂的,易实现的,同样也是强大的。 决策树本身是一连串的if-else的组合,其最关键的问题就是对于一个输入数据集我们应该怎么去寻找这个if-else规则。按照先贤们的分法主要有如下几种:ID3,C4.5,CART。本文也将介绍这三种决策树。 一、ID3 要想弄明白ID3决... 阅读全文
posted @ 2015-03-11 22:12 desperadox 阅读(1035) 评论(0) 推荐(0) 编辑
摘要:Bagging 和 Boosting 都是一种将几个弱分类器(可以理解为分类或者回归能力不好的分类器)按照一定规则组合在一起从而变成一个强分类器。但二者的组合方式有所区别。 一、Bagging Bagging的思想很简单,我选取一堆弱分类器用于分类,然后最终结果投票决定,哪个票数多就属于哪一... 阅读全文
posted @ 2015-03-11 09:55 desperadox 阅读(766) 评论(0) 推荐(0) 编辑
摘要:SVM是机器学习中神一般的存在,虽然自深度学习以来有被拉下神坛的趋势,但不得不说SVM在这个领域有着举足轻重的地位。本文从Hard SVM 到 Dual Hard SVM再引进Kernel Trick,然后推广到常用的Soft Kernel SVM。 一、Hard SVM SVM本身是从感知... 阅读全文
posted @ 2015-03-10 23:39 desperadox 阅读(2180) 评论(2) 推荐(2) 编辑
摘要:排序算法有很多种,本文主要介绍基本的排序算法和实现,并分析复杂度和稳定性。一、Ο(n2)的算法 1、插入排序 插入排序十分好理解,在无序的数组中选择一个数值,插入到有序的数组当中,这个过程是稳定的。实现代码如下: 1 template 2 void InsertionSort(vector &... 阅读全文
posted @ 2015-03-10 20:21 desperadox 阅读(208) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示