- 博客(28)
- 资源 (2)
- 收藏
- 关注
原创 leetcode---Combination Sum III---回溯
Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Example 1:Inp
2016-11-30 21:14:56 248
原创 leetcode--- Kth Largest Element in an Array---快排
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, return 5.N
2016-11-29 22:12:05 318
原创 N-gram
#include "iostream"#include "string.h"#include "string"#include "map"#include "fstream"#include "set"#include "vector"#include "stdio.h"using namespace std;vector words; //词汇库set s
2016-11-27 15:48:58 1043
原创 leetcode---House Robber II
Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time
2016-11-26 19:12:38 296
原创 中点画椭圆
void drawPix(CDC *pDC, int CentX, int CentY, int x, int y, long color){ pDC->SetPixel(CentX+x, CentY+y, color); pDC->SetPixel(CentX+x, CentY-y, color); pDC->SetPixel(CentX-x, CentY+y, color); pDC
2016-11-26 17:43:46 676
原创 RDD应用API---parallelize、Array、reduce、distinct、filter
图片来源:梁洪亮老师的课件 代码来源:Spark MLlib机器学习实践 王晓华parallelizedef parallelize[T: ClassTag](seq:Seq[T], numSlices:Int=defaultParallelism):RDD[T]第一个参数是数据,默认参数为1,表示将数据值分布在多少个数据节点中存放import org.apache.spark.{SparkC
2016-11-25 18:41:09 1978
原创 leetcode---Add and Search Word - Data structure design---Trie树
Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word or a regular expression string containing only letter
2016-11-24 22:30:38 362
原创 中点画圆
推导过程:http://blog.csdn.net/xiaowei_cqu/article/details/7909607 void WholeCircle(CDC *pDC, int CentX, int CentY, int x, int y, long color){ pDC->SetPixel(CentX + x, CentY + y, color); pDC->SetPi
2016-11-24 14:34:31 606
原创 RDD应用API---flatMap、map、reduceByKey、collect、foreach
图片来源:梁洪亮老师的课件 代码来源:Spark MLlib机器学习实践 王晓华import org.apache.spark.{SparkConf, SparkContext}object WordCount{ def main(args: Array[String]) { //SparkContext 的初始化需要一个 SparkConf 对象, Spa
2016-11-23 22:18:33 3287
原创 leetcode---Course Schedule II
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 a
2016-11-23 20:36:17 226
原创 leetcode--- Minimum Size Subarray Sum
Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead.For example, given the array [2,3,1
2016-11-22 22:22:49 332
原创 Bresenham算法画直线
推导过程:http://blog.sina.com.cn/s/blog_73428e9a01016gnp.html本程序作了进一步的简化void Bresenham_line(CDC *pDC, int x0, int y0, int x1, int y1, long color){ int dx = abs(x1 - x0); int dy = abs(y1 - y0); int
2016-11-22 18:11:55 10027 3
翻译 Resilient Distributed Datasets: A Fault-Tolerant Abstraction forIn-Memory Cluster Computing
1 Intruction问题1: 许多框架缺乏充分利用分布式内存的抽象,这使得它们不适用于大量计算都需要重用中间结果的情形,但数据重用又比较常见,比如许多迭代机器学习和图算法、交互式数据工具。 分布式内存抽象的概念——弹性分布式数据集(RDD,Resilient Distributed Datasets),在大量应用中支持数据重用,具有容错性、并行数据结构,
2016-11-22 13:10:56 3014
原创 leetcode---Implement Trie (Prefix Tree)---Trie树
Implement a trie with insert, search, and startsWith methods. class TrieNode {public: // Initialize your data structure here. bool isLeaf; TrieNode *childs[26]; TrieNode() {
2016-11-21 22:00:24 334
原创 spark---环境搭建(win7 64位 IDEA)
软件下载、安装 http://blog.csdn.net/a819825294/article/details/51627083 注意:其中,jdk 1.8不能用,需要重新百度,然后下载 补充1:在添加spark-assembly-1.3.0-hadoop2.4.0.jar时,需要先点“java”: 然后找到jar所在位置,添加进来 如果Scala SDK没有被自动识别,还需添加“Sc
2016-11-19 17:44:15 2397
原创 leetcode---Course Schedule---环的检测
There are a total of n courses you have to take, labeled from0to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a
2016-11-18 21:24:30 241
原创 leetcode---Reverse Linked List---链表
Reverse a singly linked list./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solu
2016-11-16 13:53:18 396
原创 leetcode---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 another
2016-11-15 10:25:08 233
原创 leetcode---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 for sin
2016-11-14 17:30:59 254
原创 leetcode---Bitwise AND of Numbers Range
Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4. class Solution {public: int rangeBitwiseAnd(int m, int n) { int ans = INT_MAX; while(a
2016-11-13 20:41:59 225
原创 leetcode---Number of Islands---深搜
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assu
2016-11-12 20:29:15 421
原创 leetcode---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
2016-11-11 19:49:44 292
原创 leetcode---Repeated DNA Sequences---重复子串
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.Write
2016-11-10 13:56:16 262
原创 决策树ID3 C++实现
/*思想: 每次从数据集中根据最大信息增益选取一个最好特征,将数据进行划分,每次划分都会消耗一个特征, 使得特征越来越少,当所有数据集都是同一类,或者消耗完所有特征时,划分结束。 信息熵: Entropy(D) = -sum( p_i * log_2(p_i) ) D为样本集合 1<= i <= 样本D中所包含的类别数
2016-11-10 09:53:16 3345 10
原创 AdaBoost C++实现
/* 思想: 每个弱分类器的分类结果乘以各自的alpha,相加后得到最终分类结果。 alpha根据每个弱分类器的分类错误率算出,alpha = 0.5 * ln( (1-errorRate) / errorRate ) 本算法中的若分类器为单决策树,在构建单决策树时,会根据加权错误率来衡量其性能 被分错的样本权重高,权重计算:D[i] = D[i] * e^(-1 *
2016-11-09 18:17:45 4788 1
原创 python中的队列、栈
队列定义:>>> q = []入队列:>>> q.append(1)>>> q.append(2)>>> q.append(3)出队列:>>> q.pop(0)1>>> q.pop(0)2队列顶端>>> q[0]3是否为空:>>> not qFalse栈定义:>>> s = []入栈:>>
2016-11-08 18:53:28 373
原创 leetcode---Binary Tree Right Side View---层次遍历
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree, 1
2016-11-08 18:44:47 288
原创 leetcode---Largest Number
Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result may be very large,
2016-11-04 21:41:37 234
Rx_Net35_SP1
2019-03-13
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人