自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(21)
  • 收藏
  • 关注

原创 建模与调参 lgb xgboot 朴素贝叶斯

建模与调参from sklearn.naive_bayes import GaussianNBimport pandas as pdimport numpy as npimport lightgbm as lgbimport matplotlib.pyplot as pltimport seaborn as snsfrom sklearn.feature_selection impo...

2020-04-06 00:08:25 476

原创 二手车 数据工程

二手车 数据工程import pandas as pdimport numpy as npimport matplotlibimport matplotlib.pyplot as pltimport seaborn as snsfrom operator import itemgetterdef outline(data,col_name,scale= 1): def bo...

2020-03-29 20:27:31 137

原创 二手车 数据探索性分析

数据查看,可视化 了解预测分布pycharm 使用seaborn需要加plt.show()import warningswarnings.filterwarnings('ignore')import scipy.stats as stimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport ...

2020-03-24 23:19:52 258

原创 LeetCode4. 寻找两个有序数组的中位数 c++

class Solution {public: double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) { int m = nums1.size(), n = nums2.size(); return (findKth(nums1, ...

2019-09-01 21:19:53 121

原创 leetcode 最大子序和

给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。示例:输入: [-2,1,-3,4,-1,2,1,-5,4],输出: 6解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。暴力解决方法class Solution {public: int maxSubArray(vector<int>& nu...

2019-09-01 20:38:12 68

原创 leetcode 11 c++

左右指针进行对比数值class Solution {public: int maxArea(vector<int>& height) { int left = 0; int right = height.size()-1; int totalWater = min(height[left],height[right])...

2019-09-01 20:25:56 344

原创 leetcode 292

class Solution {public: bool canWinNim(int n) { return n%4!=0; }};

2019-08-28 20:32:35 75

原创 leetcode 146 c++

class LRUCache {public: LRUCache(int capacity) { } int get(int key) { if(pos.find(key)!=pos.end()){ put(key,pos[key]->second); return pos[...

2019-08-24 21:20:16 284

原创 leetcode230 二叉搜索树中第K小的元素

由于‘中序遍历一个二叉查找树(BST)的结果是一个有序数组’ ,因此我们只需要在遍历到第k个,返回当前元素即可。class Solution {public: int kthSmallest(TreeNode* root, int k) { vector<int> nums; stack<TreeNode*> St; ...

2019-08-21 20:50:08 66

原创 leetcode235. 二叉搜索树的最近公共祖先

递归的思路class Solution {public: TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) { if(p == NULL||q==NULL||root==NULL) return NULL; if(p->val&l...

2019-08-20 21:43:36 68

原创 leetcode 104 c++

class Solution {public: int maxDepth(TreeNode* root) { if(root==nullptr) return 0; auto q = vector<TreeNode*>(); auto d = 0; q.push_back(root); ...

2019-08-18 19:42:09 207

原创 leetcode 169 c++

class Solution {public: int majorityElement(vector<int>& nums) { int major = num[0]; int count = 1; for(int i=1;i<nums.size();++i) { if(0=...

2019-08-18 19:20:33 162

原创 leetcode 10 python

class Solution: def isPowerOfTwo(self, n: int) -> bool: if n<1: return False if (n==1 or n==2): return True num,remainer=divmod(n,2) w...

2019-08-15 22:38:46 110

原创 leetcode 136

class Solution: def singleNumber(self, nums: List[int]) -> int: int singleNumber(vector<int>& nums) { single_number = 0 for num in nums: single_numb...

2019-08-15 22:20:49 61

原创 Given a set of distinct integers, nums, return all possible subsets (the power set). leetcode48

class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: res = [[]] for num in nums: for temp in res[:]: x = temp[:] x....

2019-08-15 22:12:55 364

原创 leetcode148

在 O(n log n) 时间复杂度和常数级空间复杂度下,对链表进行排序。# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def sor...

2019-08-15 21:57:17 80

原创 买卖股票的最佳时机 II

class Solution {public: int maxProfit(vector<int>& prices) { if (prices.empty()) { return 0; } int profit = 0; int buy = prices[0]; ...

2019-08-08 15:33:44 59

原创 23. 合并K个排序链表

先声明一个newhead作为dummy head,最后返回它的next作为答案,然后对于l1, l2线性扫描,每次选两者中值小的那个作为新链表的下一个节点,然后选取的链表前进一步。如果l1, l2里有一个已经结束了,就把另一个剩下的值全部直接连过来。class Solution: def mergeKLists(self, lists: List[ListNode]) -> Lis...

2019-08-06 22:30:59 80

原创 leetcode 数组中的第K个最大元素

1.简单粗暴 排序选择第i-k-1元素2.对计数数组进行遍历后(执行C[i] += C[i-1]),C[i]代表待排序数组中值小于等于i的元素个数,而C[i-1]代表值小于等于i-1的元素个数,如果 C[i-1] < k并且k <= C[i],那么待排序数组中第k小的数必定就是值为i的数!查找就可以结束了。所以只需要找到第一个满足条件k <= C[i]的i即可。class S...

2019-08-04 19:25:58 74

原创 leetcode 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。

给定一个只包括 ‘(’,’)’,’{’,’}’,’[’,’]’ 的字符串,判断字符串是否有效。有效字符串需满足:左括号必须用相同类型的右括号闭合。左括号必须以正确的顺序闭合。注意空字符串可被认为是有效字符串。将输入堆入栈中,左边输入结束后开始判断右边是否与左边一致。如果遇到右半边括号时,分类讨论:1)如栈不为空且为对应的左半边括号,则取出栈顶元素,继续循环2)若此时栈为空,则直接返...

2019-08-04 10:13:03 1090

原创 设计一个支持 push,pop,top 操作,并能在常数时间内检索到最小元素的栈。

设计一个支持 push,pop,top 操作,并能在常数时间内检索到最小元素的栈。push(x) -- 将元素 x 推入栈中。pop() -- 删除栈顶的元素。top() -- 获取栈顶元素。getMin() -- 检索栈中的最小元素。class MinStack(object): def __init__(self): self.stack = [] # 存...

2019-08-04 10:03:12 1660

空空如也

空空如也

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

TA关注的人

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