自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Parrot的专栏

记录Parrot先生的技术成长之路

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

原创 机器学习相关资源

先马一下机器学习资源

2015-09-23 20:42:24 450

原创 增量查找中位数

数字是不断进入数组的,在每次添加一个新的数进入数组的同时返回当前新数组的中位数。样例持续进入数组的数的列表为:[1, 2, 3, 4, 5],则返回[1, 1, 2, 2, 3]持续进入数组的数的列表为:[4, 5, 1, 3, 2, 6, 0],则返回 [4, 4, 4, 3, 3, 3, 3]持续进入数组的数的列表为:[2, 20, 100],则返回[2,

2015-09-08 17:03:26 1205

原创 落单的数 III

给出2*n + 2个的数字,除其中两个数字之外其他每个数字均出现两次,找到这两个数字。对于2*n+1个数字用异或就行了,而在此题将所有数异或之后得到的是两个落单的数的异或结果,没办法将结果拆分成两个落单的数。但因为两个落单数不同,所以肯定存在某个位k,使得两落单数在第k位上一个为0另一个为1,怎么找到这个k? 找异或结果中1出现的位置即可。只需找到最小的这个k,然后将在k位上为0的

2015-09-07 17:34:40 1432

原创 统计数字

计算数字k在0到n中的出现的次数,k可能是0~9的一个值例如n=12,k=1,在 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],我们发现1出现了5次 (1, 10, 11, 12)

2015-09-06 21:19:31 465

原创 Ugly number

设计一个算法,找出只含素因子3,5,7 的第 k 大的数。符合条件的数如:3,5,7,9,15......class Solution {public: /* * @param k: The number k. * @return: The kth prime number as description. */ long long k

2015-09-06 15:57:50 372

原创 查找主元素

给定一个整型数组,找出主元素,它在数组中的出现次数严格大于数组元素个数的二分之一。空间复杂度O(n)可用哈希,简单的就不给了。仅给出时间复杂度O(n),空间复杂度O(1)的算法。采用快速排序中的分割思想int parti(vector &nums, int p, int r, int tar) { int k = p; for( int

2015-09-06 13:10:29 859

转载 使用Weka进行数据挖掘

1.简介数据挖掘、机器学习这些字眼,在一些人看来,是门槛很高的东西。诚然,如果做算法实现甚至算法优化,确实需要很多背景知识。但事实是,绝大多数数据挖掘工程师,不需要去做算法层面的东西。他们的精力,集中在特征提取,算法选择和参数调优上。那么,一个可以方便地提供这些功能的工具,便是十分必要的了。而weka,便是数据挖掘工具中的佼佼者。Weka的全名是怀卡托智能分析环境(Waikato Envi

2015-06-15 23:44:22 806

原创 Course Schedule

There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as

2015-06-09 09:40:18 389

原创 Isomorphic Strings

Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with anot

2015-06-08 22:42:11 396

原创 Count Primes

Count the number of prime numbers less than a non-negative number, n.class Solution {public: int countPrimes(int n) { if(n <= 2) return 0; int res = 1;

2015-06-08 22:11:45 280

原创 Happy Number

Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares

2015-06-08 22:02:40 367

转载 聚类算法之混合高斯模型

漫谈 Clustering (3): Gaussian Mixture Model 上一次我们谈到了用 k-means 进行聚类的方法,这次我们来说一下另一个很流行的算法:Gaussian Mixture Model (GMM)。事实上,GMM 和 k-means 很像,不过 GMM 是学习出一些概率密度函数来(所以 GMM 除了用在 clustering 上之外,还经常被

2015-06-06 22:45:19 1794

原创 Unique Binary Search Trees II

Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3

2015-05-04 20:54:25 404

原创 Unique Binary Search Trees

Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \

2015-05-03 23:41:16 376

原创 Unique Paths II

Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the

2015-05-03 21:19:16 371

原创 Unique Paths

A robot is located at the top-left corner of a m x n grid (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 the

2015-05-03 20:39:30 367

原创 矩形与圆碰撞检测

说下算法思想。判断三种情况。1. 矩形四个顶点在圆内。2. 判断圆的内接正方形与矩形是否碰撞3. 判断圆上的水平左右、竖直上下四个点是否在矩形内。其中1比较简单,只需比较点到圆心距离与圆半径即可。3也简单,判断点是否在矩形内的思想是,若点在矩形外,则任意选定矩形四个顶点中的一个与该点连线,其他3点必在连线同侧。 2有点棘手,分别判断矩形的四个顶点是否在正方形内以及正方形

2015-05-01 16:59:45 1462

原创 Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cov

2015-04-29 23:21:57 378

原创 Word Break II

Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens = "

2015-04-29 09:08:14 462

原创 Convert Sorted List to Binary Search Tree

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.时间复杂度O(n log(n))/** * Definition for singly-linked list. * struct ListNode { * i

2015-04-28 20:48:53 374

原创 Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.很经典的一道题。先将新旧链表按Z字形连起来,再更新新链表的r

2015-04-28 19:50:12 370

原创 Insertion Sort List

Sort a linked list using insertion sort./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * };

2015-04-27 21:57:10 407

原创 Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked li

2015-04-27 12:55:48 339

原创 Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. * struct ListNode { * int val;

2015-04-27 12:45:00 324

原创 Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.算法一:用multiset对节点排序,仅在第一次排序时花费O(k log(k))时间,后面每次更新一个节点费时 log(k)。时间复杂度O(n log(k))。 但测试效果不是很理想。

2015-04-26 22:31:07 375

原创 Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of

2015-04-26 21:40:26 339

原创 Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->

2015-04-26 21:21:22 393

原创 Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5/** * Definition fo

2015-04-26 21:05:04 392

原创 Reorder List

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.For example,Given {1,2,3,4}, reorder it t

2015-04-26 20:18:42 330

原创 Reverse Linked List II

Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy t

2015-04-26 19:48:01 351

原创 Reverse Nodes in k-Group e

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is

2015-04-26 19:13:02 386

原创 Rotate List

Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL./** * Definition for singly-

2015-04-26 18:36:17 333

转载 Cocos2d-x 3.0 开发(八)骨骼动画的动态换肤

1、   概述    游戏中人物的状态会发生改变,而这种改变通常要通过局部的变化来表现出来。比如获得一件装备后人物形象的改变,或者战斗中武器、防具的损坏等。这些变化的实现就要通过动态换肤来实现。在接下来的这个Demo中,点击屏幕会动态更换小人手中的武器。先上图:  2、制作小人    首先我们先制作一个UI小人,并将显示资源绑定到骨骼上。有不太明白的

2015-04-24 12:28:02 1007

原创 Word Break

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet"

2015-04-17 22:07:30 365

原创 Bitwise AND of Numbers Range

Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4.观察连续若干个数在各个bit上的分布情况,可以得出分布规律。在第k位,总是会交替出现2^(k-1)个0和2^(k-1)个1.所以如果n-m+1大于2^(k-1),则在后k位的每一位上,至少会有一个数是0,所以n-

2015-04-17 21:17:35 419

原创 C++之多重继承

C++多重继承是很大一块,也不多说,就说一两点。首先探究下多重继承下派生类的内部是怎么布局的。且看下面一个例子例1:#includeusing namespace std;class A{public: int x;public: A(){ cout<<"调用A构造函数!\n";} A(const A& a){ cout<<"调用拷贝构造函数!\n";} void te

2015-04-15 19:19:28 576

原创 C++之局部static变量

static其他特性不多说,就说一点,当变量为局部static变量时,如果不知道它的特性你会欲哭无泪。今天在debug项目时就发现了这个坑。直接看两个例子吧。#includeusing namespace std;int cnt=1;void f(){ static int test = cnt; cout<<test<<endl; cnt++;}int main(){

2015-04-15 14:01:05 3114 1

原创 Sort List(四种算法)

Sort a linked list in O(n log n) time using constant space complexity.算法一:快速排序。 因为链表是单向,所以有很多细节要注意,比如quick_sort(p,r)排序的区间其实是[p->next,r->next],因为单向链表不能回头。/** * Definition for singly-linked lis

2015-04-12 12:02:31 997

原创 Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y

2015-04-11 23:11:33 356

原创 House Robber

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house

2015-04-11 22:39:24 339

空空如也

空空如也

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

TA关注的人

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