- 博客(26)
- 资源 (5)
- 收藏
- 关注
原创 图详细解答!
#include<iostream>#include<stdlib.h>#define maxvn 10using namespace std;typedef char VertexType;//定义图的存储数据类型typedef struct ArcNode{ int adjvesx; struct ArcNode *nextarc;...
2019-09-07 22:38:28
749
原创 leetcode 208 Trie前缀树
class Trie{public: bool indicate; //数据成员;每个节点的状态指示器,判断它及其之前的节点是否构成一个完整的字符串 Trie* pnext[26]; //数据成员;因为只限定指向了小写字母(26个英文字母) /** Initialize your data structure here. */ Tri...
2019-09-05 18:34:52
162
原创 leetcode 230 在二叉搜索树中找出第k小的元素(二分查找法)
/*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode(int x) : val(x), left(NULL), right(NULL) {}* };*/clas...
2019-09-05 11:49:07
190
原创 leetcode 145 后序遍历(迭代版) 双栈法,绝无仅有!!
class Solution{public: vector<int> postorderTraversal(TreeNode* root) { vector<int> v; if(root==nullptr) return v; stack<TreeNode*> s1,s2; //定义两个栈,s2中存放后序...
2019-09-04 11:57:27
374
原创 leetcode 94 二叉树的中序遍历迭代版
解法一:class Solution{public: void goLongLeftBranch(TreeNode* root,stack<TreeNode*> s) //与前序遍历的沿最左侧通路不同,它只记录而不访问 { while(root) { s.push(root); ...
2019-09-04 10:13:22
92
原创 leetcode 先序遍历迭代版的两种解法
解法一:先序序列分为两段:沿最左侧通路自上而下访问的各顶点(以v表示),以及自底向上遍历的右子树(存储于s之中)class Solution{public: void visitAlongLeftBranch(TreeNode* root,vector<int>& v,stack<TreeNode*>& s){ while(root)...
2019-09-04 09:30:58
189
原创 leetcode 513 找出树的左下角的值
/*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode(int x) : val(x), left(NULL), right(NULL) {}* };*/clas...
2019-09-03 09:18:28
111
原创 leetcode 判断树是否适度平衡(即是否为AVL树)
/*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode(int x) : val(x), left(NULL), right(NULL) {}* };*/clas...
2019-09-02 10:40:14
431
原创 leetcode160 两个链表交点
class Solution {public: ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) { if(!headA || !headB) return nullptr; ListNode *countA = headA; ListNode *count...
2019-08-30 22:34:55
129
原创 反转链表
链接:https://www.nowcoder.com/questionTerminal/75e878df47f24fdc9dc3e400ec6058ca?f=discussion来源:牛客网//第一种方法是:非递归方法/*struct ListNode {int val;struct ListNode *next;ListNode(int x...
2019-08-30 21:21:18
99
原创 以人眼进行人脸对齐
//根据眼睛坐标对图像进行仿射变换//src - 原图像//landmarks - 原图像中68个关键点Mat getwarpAffineImg(Mat &src, vector<Point2f> &landmarks){ Mat oral;src.copyTo(oral); for (int j = 0; j < landm...
2019-08-30 17:03:30
321
原创 opencv只进行人脸检测
#include <opencv2/objdetect/objdetect.hpp>#include <opencv2/highgui/highgui.hpp>#include <opencv2/imgproc/imgproc.hpp>#include <iostream>#include <stdio.h>...
2019-08-29 16:24:38
178
原创 leetcode 69 采用牛顿法求解平方根
class Solution{public: //对一个非负整数x来说,其平方根不会超过x/2+1,因此此题变为了这样的一个二分查找算法:在[0,x/2+1]内找到一个数,使其平方等于x int mySqrt(int x) { if (x == 0) return 0; double last=0; double res=...
2019-08-21 11:02:00
127
原创 leetcode 69 使用二分查找法求解平方根
class Solution{public: //对一个非负整数x来说,其平方根不会超过x/2+1,因此此题变为了这样的一个二分查找算法:在[0,x/2+1]内找到一个数,使其平方等于x int mySqrt(int x) { long long i{0}; long long j{x/2+1}; while(i<=...
2019-08-21 11:00:05
264
原创 leetcode 455 分发饼干
class Solution{public: int findContentChildren(vector<int>& g, vector<int>& s) { int gi{0},si{0},count{0}; sort(g.begin(),g.end()); //等价于 sort(begin(g),...
2019-08-20 23:12:26
86
原创 leetcode 347 找出数组中最常出现的k个数
class Solution{public: using iipair=pair<int,int>; //定义pair<K,T>的类型别名 class functortocomp //以函数对象去自定义谓词 { public: bool operator()(const iipa...
2019-08-20 21:01:17
206
原创 leetcode 215 使用快速选择找出第n-k小的元素
class Solution{public: int quickselect(vector<int>& nums,int k,int lo,int hi) { int n=nums.size(); if(lo>=hi) return 0; //递归基 int temp=nums.at(0); /...
2019-08-19 22:06:41
214
原创 leetcode 215 找出第k大的元素
class Solution{public: void insertandadjustup(vector<int> &num,vector<int> &nums,int n) //插入并上滤 { num.insert(end(num),nums[n]); int j; while((j=...
2019-08-19 12:24:34
186
原创 基数排序
class Solution{public: int maxbit(vector<int>& nums) //求最大位数 { int t=1; //t为最大位数 int p=10; for(int i=0;i<nums.size();++i) { whil...
2019-08-17 00:03:41
74
原创 基数排序
class Solution{public: int maxbit(vector<int>& nums) //求最大位数 { int t=1; //t为最大位数 int p=10; for(int i=0;i<nums.size();++i) { whil...
2019-08-17 00:03:11
122
原创 正确而简洁的以链表实现的桶排序
#include<iostream>typedef struct node{ int key; struct node* next;}keynode;/***********struct node{ int key; struct node* next;}typedef node* keynode;************/ int B...
2019-08-16 23:22:43
221
原创 堆类
class Solution{public: class Heap { private: int* _Heap=nullptr; //int index; int maxsize; public: Heap(){} Heap(vector<int>& nums)...
2019-08-16 11:36:37
231
原创 归并排序
class Solution{public: void Merge(vector<int>& nums,int lo,int mi,int hi) { int* a=&*begin(nums)+lo; int lb=mi-lo; int* b=new int[lb]; for(int i=0;i<lb;++i)...
2019-08-16 11:35:16
110
原创 堆排序
class Solution{public: int MaxDadandSons(vector<int>& nums,int i) { int j=2*i+1; int k=2*i+2; //右子节点 if(k>=0 && k<=nums.size()-1) return (nums[j]...
2019-08-16 09:30:23
110
翻译 libsvm最全使用说明
连接,https://github.com/cjlin1/libsvm,这里面可以直接下载libsvm。
2018-06-07 15:26:56
178
原创 神经网路,python描述,最全注释!!
import random #引入random模块import numpy as np #引入numpy模块并将其记作npclass Network(object): #定义一个network(网络)类 def __init__(self,sizes): ...
2018-04-30 09:34:00
490
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人