自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(26)
  • 收藏
  • 关注

转载 [Leetcode]Swap Nodes in Pairs

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 algorithm should use only ...

2015-03-17 22:46:00 77

转载 [Leetcode]Sort Colors

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, white and blue.Here, we will use the intege...

2015-03-17 22:44:00 75

转载 [Leetcode]Unique Paths

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 in time. The robot is trying to reach t...

2015-03-17 22:41:00 91

转载 [Leetcode]Find Minimum in Rotated Sorted Array

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 may assume no duplicate exists in the...

2015-03-17 22:40:00 56

转载 [Leetcode]Merge Two Sorted Lists

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.一直没想出原址排序的办法,只能额外开辟空间了。 1 class Solution { ...

2015-03-15 23:24:00 49

转载 [Leetcode]Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分治是比较好而且容易想到的思路。 1 class Solution { 2 public: 3 TreeNode *mergeAToT(vector<int&gt...

2015-03-15 23:07:00 54

转载 [Leetcode]Unique Paths

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 in time. The robot is trying to reach t...

2015-03-15 22:44:00 45

转载 [Leetcode]Climbing Stairs

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 to the top?简单动规。 1 class Soluti...

2015-03-15 22:10:00 37

转载 [Leetcode]Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear onlyonce.简单题,注意逻辑顺序就好了。 1 class Solution { 2 public: 3 ListNode *deleteDuplicates(ListNode *head) {...

2015-03-15 21:46:00 54

转载 [Leetcode]Majority Element

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 array is non-empty and the majority element...

2015-03-15 20:48:00 60

转载 [Leetcode]Maximum Subarray

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,−5,4],the contiguous subarray[4,−1,2,1]h...

2015-03-15 00:29:00 51

转载 [Leetcode]Search Insert Position

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 order.You may assume no duplicates in the arr...

2015-03-15 00:23:00 75

转载 [Leetcode]Binary Tree Inorder Traversal

Given a binary tree, return theinordertraversal of its nodes' values.和preorder是一样的,把左子节点一直压入到栈中,直到没有左子节点为止,然后出栈访问,存储右子节点。 1 vector<int> inorderTraversal(TreeNode *root) 2 { 3 ...

2015-03-15 00:08:00 43

转载 [Leetcode]Populating Next Right Pointers in Each Node

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 pointers are set toNULL.Note:You ma...

2015-03-14 23:39:00 50

转载 [Leetcode]Binary Tree Preorder Traversal

Given a binary tree, return thepreordertraversal of its nodes' values.简单题,递归和迭代都可以解。 1 class Solution { 2 public: 3 vector<int> preorderTraversal(TreeNode *root) { 4 ...

2015-03-14 23:18:00 48

转载 [机器学习]Generalized Linear Model

  最近一直在回顾linear regression model和logistic regression model,但对其中的一些问题都很疑惑不解,知道我看到广义线性模型即Generalized Linear Model后才恍然大悟原来这些模型是这样推导的,在这里与诸位分享一下,具体更多细节可以参考Andrew Ng的课程。  一、指数分布  广义线性模型都是由指数分布出...

2015-03-13 22:51:00 130

转载 [Leetcode]Linked List Cycle

Given a linked list, determine if it has a cycle in it.简单题,只要知道快慢指针这个技巧就很容易解了。 1 class Solution { 2 public: 3 bool hasCycle(ListNode *head) { 4 if(head == NULL) 5 ...

2015-03-12 23:51:00 51

转载 [Leetcode]Excel Sheet Column Number

Given a column title as appear in an Excel sheet, return its corresponding column number.本质上是一个进制转换问题。1 class Solution {2 public:3 int titleToNumber(string s) {4 int re...

2015-03-12 23:45:00 54

转载 [Leetcode]Unique Binary Search Trees

Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?简单动态规划。判别每个左右子树各有多少种情况,然后相乘就可以了,而且是BST,注意这条件就可以解了。它的状态转移方程为:        for j<i:      a[i]+ = a[j-1]...

2015-03-12 23:28:00 49

转载 [Leetcode]Same Tree

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 and the nodes have the same value.同样是树的问...

2015-03-12 22:24:00 46

转载 [Leetcode]Maximum Depth of Binary Tree

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 leaf node.解决树的问题很大一部分都是可以用递归来做的。 1 c...

2015-03-12 22:17:00 71

转载 [Leetcode]Single Number && Single Number II

Given an array of integers, every element appearstwiceexcept for one. Find that single one.非常简单的一道题。直接相异或剩下的那个数就是答案。原理是两个相等的数异或的值为0。1 class Solution {2 public:3 int singleNumber...

2015-03-12 22:12:00 105

转载 [机器学习]决策树

  决策树是简单的,易懂的,易实现的,同样也是强大的。  决策树本身是一连串的if-else的组合,其最关键的问题就是对于一个输入数据集我们应该怎么去寻找这个if-else规则。按照先贤们的分法主要有如下几种:ID3,C4.5,CART。本文也将介绍这三种决策树。  一、ID3  要想弄明白ID3决策树,我们必须先了解信息论的开创者——香农对信息是如何量化的。  (1)熵...

2015-03-11 22:12:00 73

转载 [机器学习]Bagging and Boosting

  Bagging 和 Boosting 都是一种将几个弱分类器(可以理解为分类或者回归能力不好的分类器)按照一定规则组合在一起从而变成一个强分类器。但二者的组合方式有所区别。  一、Bagging  Bagging的思想很简单,我选取一堆弱分类器用于分类,然后最终结果投票决定,哪个票数多就属于哪一类。不过Bagging的一个重要步骤就是在训练每一个弱分类器的时候不是用整个...

2015-03-11 09:55:00 81

转载 [机器学习]SVM原理

  SVM是机器学习中神一般的存在,虽然自深度学习以来有被拉下神坛的趋势,但不得不说SVM在这个领域有着举足轻重的地位。本文从Hard SVM 到 Dual Hard SVM再引进Kernel Trick,然后推广到常用的Soft Kernel SVM。  一、Hard SVM  SVM本身是从感知机算法演变而来,感知机算法是在一个线性可分的数据集中找到一个分类超平面,尽可...

2015-03-10 23:39:00 128

转载 [算法]排序算法综述

排序算法有很多种,本文主要介绍基本的排序算法和实现,并分析复杂度和稳定性。一、Ο(n2)的算法  1、插入排序  插入排序十分好理解,在无序的数组中选择一个数值,插入到有序的数组当中,这个过程是稳定的。实现代码如下:  1 template <typename T>2 void InsertionSort(vector<T> ...

2015-03-10 20:21:00 128

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除