
算法
Line_Walker
微信公众号:芥子观须弥
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Adaboost 算法介绍(针对算法面试)
Adaboost 算法介绍1. Adaboost简介1.1 集成学习(ensemble learning)背景介绍集成学习(ensemble learning)通过构建并结合多个学习器(learner)来完成学习任务,通常可获得比单一学习器更良好的泛化性能(特别是在集成弱学习器(weak learner)时)。目前集成学习主要分为2大类:一类是以bagging、Random Forest...原创 2019-04-11 16:53:53 · 1394 阅读 · 0 评论 -
LeetCode104. Maximum Depth of Binary Tree 二叉树的最大深度
1. problem descriptionGiven 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.Note: A leaf is a...原创 2019-08-16 23:18:06 · 168 阅读 · 0 评论 -
LeetCode235 Lowest Common Ancestor of a Binary Search Tree二叉搜索树的最近公共祖先
1. problem descriptionGiven 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 ancest...原创 2019-08-21 22:12:01 · 148 阅读 · 0 评论 -
LeetCode136 Single Number 只出现一次的数字
1. problem descriptionGiven a non-empty array of integers, every element appears twice except for one. Find that single one.给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。Note:Your algorithm should have a l...原创 2019-08-12 21:21:28 · 177 阅读 · 0 评论 -
LeetCode231 Power of Two 2的幂
1. problem descriptionGiven an integer, write a function to determine if it is a power of two.Example 1:Input: 1Output: trueExplanation: 2^0 = 1Example 2:Input: 16Output: trueExplanation: ...原创 2019-08-16 00:08:22 · 138 阅读 · 0 评论 -
LeetCode78 Subsets子集
1. problem descriptionGiven a set of distinct integers, nums, return all possible subsets (the power set).给定一组不含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集)。Note: The solution set must not contain duplicate sub...原创 2019-08-11 21:08:55 · 170 阅读 · 0 评论 -
LeetCode148 Sort List 排序链表
1. problem descriptionSort a linked list in O(n log n) time using constant space complexity(在 O(n log n) 时间复杂度和常数级空间复杂度下).eg1:Input: 4->2->1->3Output: 1->2->3->4eg2:Input: -...原创 2019-08-10 21:18:36 · 137 阅读 · 0 评论 -
LeetCode230. Kth Smallest Element in a BST 二叉搜索树中第K小的元素
1. problem descriptionGiven a binary search tree, write a function kthSmallestto find the kth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.(你可以假设 k 总是有...原创 2019-08-19 23:08:44 · 166 阅读 · 0 评论 -
LeetCode124 Binary Tree Maximum Path Sum 二叉树中的最大路径和
1. problem descriptionGiven a non-empty binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the ...原创 2019-08-19 22:57:02 · 159 阅读 · 0 评论 -
LeetCode122 Best Time to Buy and Sell Stock II 买卖股票最佳时机
1. problem descriptionSay you have an array for which the i^th element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as...原创 2019-08-09 19:41:10 · 271 阅读 · 0 评论 -
LeetCode169 Majority Element 求众数
1. problem descriptionGiven an array of size n, 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...原创 2019-08-13 22:53:51 · 140 阅读 · 0 评论 -
LeetCode23 Merge k Sorted Lists(合并K个排序链表)
1. problem descriptionMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.合并 k 个排序链表,返回合并后的排序链表。请分析和描述算法的复杂度。Input:[1->4->5,1->3->4,2-...原创 2019-08-08 21:09:12 · 186 阅读 · 0 评论 -
LeetCode215 Kth Largest Element in an Array 数组中的第K个最大元素
problem descriptionFind 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.Example 1:Input: [3,2,1,5,6,4] and k...原创 2019-08-06 12:47:18 · 131 阅读 · 0 评论 -
LeetCode20 Valid Parentheses 有效的字符串
problem descriptionGiven a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed by...原创 2019-08-04 22:06:10 · 127 阅读 · 0 评论 -
LeetCode 155 Min Stack最小栈
1. problem descriptionDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.设计一个支持 push,pop,top 操作,并能在常数时间内检索到最小元素的栈。push(x) – Push element x onto stack....原创 2019-08-04 16:42:47 · 180 阅读 · 0 评论 -
C++实现不定长数组输入(不需要定义分配空间大小)
问题:比如:要输入1 2 3 4 5 6 ......一串整型数据,不知道要输入数据的长度是多少,现在要存到一个数组中,怎么办?换一种说法就是,其实懒懒的我在想c++能不能实现python里array=input();这种非常简单的、不需要确定数组长度就能输入一串数字存起来的效果网上的一些办法:malloc方法,其实也要说明分配空间的大小; 直接定义一个较大的数组,这不是...原创 2019-01-28 22:28:06 · 23010 阅读 · 5 评论 -
LeetCode 236 Lowest Common Ancestor of a Binary Tree 二叉树的最近公共祖先
1. problem descriptionGiven a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is define...原创 2019-09-02 00:17:41 · 159 阅读 · 0 评论