- 博客(269)
- 资源 (1)
- 收藏
- 关注
原创 最大子数组 III
给定一个整数数组和一个整数 k,找出 k 个不重叠子数组使得它们的和最大。每个子数组的数字在数组中的位置应该是连续的。 返回最大的和。 注意事项 子数组最少包含一个数 样例 给出数组 [-1,4,-2,3,-2,3] 以及 k = 2,返回 8public class Solution { /** * @param nums: A list of integers
2017-07-15 17:09:48
580
原创 最大子数组 II
给定一个整数数组,找出两个 不重叠 子数组使得它们的和最大。 每个子数组的数字在数组中的位置应该是连续的。 返回最大的和。 注意事项 子数组最少包含一个数样例 给出数组 [1, 3, -1, 2, -1, 2] 这两个子数组分别为 [1, 3] 和 [2, -1, 2] 或者 [1, 3, -1, 2] 和 [2],它们的最大和都是 7 挑战 要求时间复杂度为 O(n)publi
2017-07-15 16:51:49
409
原创 337. House Robber III
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After a tour,
2017-05-01 21:04:43
370
原创 324. Wiggle Sort II
Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]….Example: (1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1, 5, 1, 6]. (2) Given nums = [1
2017-05-01 20:21:34
353
原创 2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it
2017-04-29 20:23:21
248
原创 windows10+python3环境搭建
在windows10上搭建好python3之后,用pip安装所需要的包。这里没有使用anaconda,python和pip自行安装。 http://www.lfd.uci.edu/~gohlke/pythonlibs/这里有所需要的pakage。 比如下载numpy‑1.12.1+mkl‑cp36‑cp36m‑win_amd64.whl 需要注意cp36是python的版本是python3.
2017-04-29 10:05:09
390
原创 gbdt源码阅读
regressiontree. main函数:训练样本,最大深度,叶子节点最小样本数,特征采样,数据采样。加载训练样本,利用样本构建regressiontree,对训练样本(这里有些问题,实际上应该对样本进行划分)进行预测。 RegressionTree: fit:选取采样特征,递归构建树,选取切分节点(特征)。 split_node: 选取切分点,如果深度达到最大深度或者切分之后左右树没有
2017-04-10 20:44:41
1171
转载 gbdt和随机森林
转载http://blog.youkuaiyun.com/keepreder/article/details/47272779 相同点: 1.都是多棵树组成 2.结果由多棵树决定 不同点: 1.随机森林可以是分类树或者回归树,gbdt是回归树。 2.随机森林是投票的方式决定结果,gbdt是各个树的加和作为最终结果。 3.随机森林中的树可以并行构建,gbdt需要串行。 4.随机森林对异常值不敏感,
2017-04-10 15:55:04
627
原创 452. Minimum Number of Arrows to Burst Balloons
There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it’s horizontal, y-coordina
2017-04-04 21:14:40
233
原创 213. 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, all
2017-04-04 20:12:40
300
原创 47. Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations: [ [1,1,2], [1,2,1], [2,1,1]
2017-04-04 19:55:41
367
原创 114. Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example, Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1 \ 2 \ 3
2017-04-04 19:42:24
181
原创 300. Longest Increasing Subsequence
Given an unsorted array of integers, find the length of longest increasing subsequence.For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subsequence is [2, 3, 7, 101], therefore
2017-04-04 19:13:53
199
原创 402. Remove K Digits
Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.Note:The length of num is less than 10002 and will be ≥ k.The
2017-03-28 20:10:23
347
原创 406. Queue Reconstruction by Height
Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this p
2017-03-28 19:25:58
315
原创 409. Longest Palindrome
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example “Aa” is not consider
2017-03-28 19:25:20
303
原创 414. Third Maximum Number
Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1:Input: [3, 2, 1]Output
2017-03-28 15:42:00
261
原创 168. Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example:1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB public class Solution { public String con
2017-03-26 19:46:25
267
原创 117. Populating Next Right Pointers in Each Node II
Follow up for problem “Populating Next Right Pointers in Each Node”.What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant extra space.
2017-03-26 19:38:53
287
原创 445. Add Two Numbers II
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it
2017-03-26 19:17:36
313
原创 73. Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up: Did you use extra space? A straight forward solution using O(mn) space
2017-03-26 18:59:13
381
原创 297. Serialize and Deserialize Binary Tree
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be
2017-03-26 17:38:14
219
原创 116. Populating Next Right Pointers in Each Node
Given a binary treestruct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next;}Populate each next pointer to point to its next right node. If there is no next right node,
2017-03-26 17:02:56
256
原创 268. Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1, 3] return 2.a^b^b = apublic class Solution { pub
2017-03-26 16:03:03
202
原创 218. The Skyline Problem
A city’s skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as
2017-03-26 15:51:29
375
原创 235. Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two
2017-03-26 13:40:51
213
原创 273. Integer to English Words
Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example, 123 -> “One Hundred Twenty Three” 12345 -> “Twelve Thousand Three Hu
2017-03-26 13:26:54
257
原创 138. 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./** * Definition for singly-linked lis
2017-03-26 12:54:42
181
原创 419. Battleships in a Board
Given an 2D board, count how many battleships are in it. The battleships are represented with ‘X’s, empty slots are represented with ‘.’s. You may assume the following rules:You receive a valid board,
2017-03-26 12:25:12
275
原创 xgboost
摘录自知乎。https://www.zhihu.com/question/41354392xgboost和gbdt的区别,为什么快?如何支持并行? 1.传统gbdt是用CART作为基分类器,xgboost还支持线性分类器。此时xgboost相当于带l1和l2正则化项的逻辑回归(分类问题)或者线性回归(回归问题)。 2.gbdt优化时只用到了一阶求导,xgboost对代价函数进行二阶泰勒展开,同时
2017-03-20 12:18:57
1877
原创 删除链表中倒数第n个节点
给定一个链表,删除链表中倒数第n个节点,返回链表的头节点。 样例 给出链表1->2->3->4->5->null和 n = 2.删除倒数第二个节点之后,这个链表将变成1->2->3->5->null.挑战 O(n)时间复杂度/** * Definition for ListNode. * public class ListNode { * int val; * Lis
2017-03-19 10:19:31
318
原创 翻转链表 II
翻转链表中第m个节点到第n个节点的部分 样例 给出链表1->2->3->4->5->null, m = 2 和n = 4,返回1->4->3->2->5->null挑战 在原地一次翻转完成/** * Definition for ListNode * public class ListNode { * int val; * ListNode next; *
2017-03-19 09:56:36
214
原创 寻找旋转排序数组中的最小值 II
假设一个旋转排序的数组其起始位置是未知的(比如0 1 2 4 5 6 7 可能变成是4 5 6 7 0 1 2)。你需要找到其中最小的元素。数组中可能存在重复的元素。 样例 给出[4,4,5,6,7,0,1,2] 返回 0public class Solution { /** * @param num: a rotated sorted array * @retur
2017-03-18 21:13:28
279
原创 153. Find Minimum in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exist
2017-03-18 17:15:48
338
原创 机器学习-1
基本问题的经典算法 分类:svm、最大熵、adaboost、分类回归树、随机森林 回归:分类回归树、随机森林、GBDT 排序:GBRank 聚类:K-Means 结构标注:隐马尔可夫模型、条件随机场。机器学习=表示(算法、特征的表示)+评价(loss+cost评价算法好坏的函数)+优化(寻找使评价函数得分最高的搜索方法比如梯度下降、牛顿法)如何权衡训练误差和预测误差(拟合能力和泛化能力,b
2017-03-17 16:57:14
354
原创 广告点击率预估模型
广告点击价值由广告主定价,每次广告投放是投放预期收益最高的广告。点击率预测越准确,越接近最大化收益。 挖掘用户日志,根据日志中行为信息给用户打标签。特征提取-单属性特征 广告特征:广告商,广告集团,广告品种,广告标题等。 用户特征:用户cookie,搜索关键字,tag 上下文特征:页面主题关键字,正文关键字,广告位,browser,page attribute特征提取-交叉特征 静态特征-
2017-03-17 12:31:15
2832
原创 151. Reverse Words in a String
Given an input string, reverse the string word by word.For example, Given s = “the sky is blue”, return “blue is sky the”.Update (2015-02-12): For C programmers: Try to solve it in-place in O(1) spa
2017-03-16 23:41:14
477
原创 451. Sort Characters By Frequency
Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input: “tree”Output: “eert”Explanation: ‘e’ appears twice while ‘r’ and ‘t’ both appear once. So ‘e’ must
2017-03-16 17:16:10
351
原创 397. Integer Replacement
Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2. If n is odd, you can replace n with either n + 1 or n - 1. What is the minimum number of replacement
2017-03-16 16:48:56
244
ubuntu linux镜像下载
2012-10-10
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人