自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 c++ 二叉树打印节点路径

leetcode上有道题是关于path sum的,我第一时间的做法是用二叉树的路径去与sum比较。所以需要去打印出二叉树的节点路径,以下是用回溯法。 1 #include<iostream> 2 #include<vector> 3 using namespace std; 4 5 struct TreeNode { 6 in...

2019-02-12 10:48:00 465

转载 python ---- ftp传输服务器[在本地建一个站点方便局域网访问]

分享一个python 脚本 关于建立ftp服务器以供局域网内的同事访问 ftp.py 1 # -*- coding:utf-8 -*- 2 import os 3 from pyftpdlib.authorizers import DummyAuthorizer 4 from pyftpdlib.handlers import FTPHandler 5 fro...

2018-10-31 22:27:00 158

转载 c++ template queue,stack ( c++用template实现队列、栈数据结构)

今天在看单元测试的时候无意中看到google gtest的例子有个实现Queue队列的数据结构它是用单链表实现的。索性今天就分享一下队列和栈这两种实现方法。Queue单链表实现 1 // Copyright 2005, Google Inc. 2 // All rights reserved. 3 // 4 // Redistribution an...

2018-09-29 18:42:00 316

转载 map存放结构体、类的例子

面试中问到了一个问题,定义一个map<A,int>,key是一个类,value是一个int型值,问这个类有什么限制吗?当时没想出来,回头自己试的时候确实编译不过,报的错误是error: no match for ‘operator<’ (operand types are ‘const A’ and ‘const A’) { return __x &...

2018-08-31 15:37:00 1142

转载 c++ 中对关联容器和序列容器的 erase()方法

面试中经常会问到序列式容器、关联容器中迭代器失效的问题,其核心问题的是调用c++方法中的erase(),迭代器iter还是否有效。搞清楚以下几点:1)earse()方法可以返回下一个有效的迭代器2)删除序列式容器(如vector,deque)中当前的iterator会使后面所有元素的iterator都失效3)对于关联容器(如map, set, multimap,multi...

2018-08-31 14:27:00 283

转载 c++ 内存对齐规则及例子

sizeof() 输出值是多少?面试中也是经常会问到的,这里又了解了内存对齐的原则,作个记录。 1 #include <iostream> 2 using namespace std; 3 4 //内存对齐的规则: 5 //默认条件下,内存对齐是以class/struct中最大的那个基本类型为基准的(x倍数),如果class/struct中有自定义类...

2018-07-20 15:04:00 140

转载 LRU (近期最少使用)算法 c++实现

前言这两天碰到面试题,说是页面调度算法,之前在操作系统书上有了解过,LRU(近期最少使用),还有OPT(最佳页面替换算法)、FIFO(先进先出页面置换算法),今天先来实现LRU 最近最少使用。LRU 原理LRU(Leastrecentlyused,最近最少使用)算法根据数据的历史访问记录来进行淘汰数据,其核心思想是“如果数据最近被访问过,那么将来被访问的几率也更高”。...

2018-07-13 16:32:00 440

转载 数据结构:单链表就地逆置(递归方法)解析

先上代码: 1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 5 struct ListNode { 6 int value; 7 ListNode *next; 8 ListNode(int x) :value(x)...

2018-06-16 17:20:00 1818

转载 Refused to load the script xxxxxx because it violates the following Content Security Policy directiv...

今天在公司碰到一个这样的问题:大致问题是这样的,我把新生成的国外cdn路径放到页面上来用来查看,发现会出现如下类似的错误信息Refused to load the script xxxxxx because it violates the following Content Security Policy directive:"script-src 'self' xxxxxxxx...

2018-06-06 18:41:00 3277

转载 linux打印地址时是0xXXXX XXXX XXXX,为什么64位机指针只用48个位?

Example: 1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <iostream> 4 #include <string> 5 #include <functional> //std::function 6 7 using ...

2018-05-31 10:16:00 2114

转载 安装coreML避坑

官网github地址:https://github.com/tf-coreml/tf-coreml我是先是用这条命令安装好了好久pip install -U tfcoreml遇到很多问题,最后在numpy版本号冲突结束了,又不想乱卸载,所以我接着试着源码安装。Install From SourceTo build and install from source...

2018-04-14 12:16:00 196

转载 c++中模板是什么?为什么要定义模板?

一、c++中模板是什么?首先:1 int Max(int x, int y)2 {3 return x > y ? x : y;4 }5 6 float Max(float a,float b)7 {8 return a > b ? a : b;9 }通常我们想要比较不同数据类型的时候不得不定义两种不同的函数...

2018-04-09 13:19:00 369

转载 动态规划系列 Leetcode 198. 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 ...

2018-04-07 16:30:00 63

转载 动态规划系列 Leetcode 70. Climbing Stairs

You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note:Givennwill be a pos...

2018-04-07 16:27:00 70

转载 Leetcode 108. Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth o...

2018-04-07 16:22:00 62

转载 Leetcode 450. Delete Node in a BST

Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.Basically, the deletion can be divide...

2018-04-07 16:16:00 66

转载 Leetcode 538. Convert BST to Greater Tree

Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.E...

2018-04-07 16:08:00 79

转载 Leetcode 449. Serialize and Deserialize BST

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 ...

2018-04-07 15:59:00 87

转载 机器学习入门(1)------python基础

环境:Python 3.6.4 |Anaconda, Inc.Python常用容器类型1.list 1 l = [1, 'a', 2, 'b'] 2 print(type(l)) 3 print('修改前:', l) 4 5 # 修改list的内容 6 l[0] = 3 7 print('修改后:', l) 8 9 # 末尾添加元素...

2018-04-06 21:05:00 131

转载 Leetcode 23. Merge k Sorted Lists

Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.题目意思:k个有序链表合并后仍为一个有序链表解题思路:我先将链表存储在vector中,然后我用新的vector去存储链表中的每个节点,之后快速排序(stl std::sort),然后再对...

2018-03-24 22:41:00 81

转载 Leetcode 315. Count of Smaller Numbers After Self

You are given an integer arraynumsand you have to return a newcountsarray. Thecountsarray has the property wherecounts[i]is the number of smaller elements to the right ofnums[i].Exampl...

2018-03-24 22:31:00 94

转载 Leetcode 33. Search 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 7might become4 5 6 7 0 1 2).You are given a target value to search. If found...

2018-03-24 22:10:00 106

转载 Leetcode 34 Search for a Range

Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order ofO(logn).If the...

2018-03-24 21:28:00 88

转载 Leetcode 35. Search Insert Position

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the arr...

2018-03-24 19:41:00 82

转载 c++ dynamic_cast 和 static_cast 的区别

今天在看王道宝典的时候看到dynamic_cast ,一直都没用过,也不了解,今天来总结一下。dynamic_cast 和 static_cast 都可以用来强制转换指针类型,但不同的是dynamic_cast在进行类层次间的下行转换时更加安全。dynamic_cast 运算符可以在执行期决定真正的类型。如果下行转换是安全的(也就是说,如果基类指针或者引用确实指向一个派生类对象)...

2018-03-24 18:53:00 618

转载 const 相关知识 const和指针、const和引用

以前老是对const概念不清不楚,今天算是好好做个笔记总结一下。以下内容包括1)常量指针(指针本身是常量),2)指针常量(指针指向的是常量对象),3)常量引用,4)const成员函数。常量指针,指针是一个常量,常量指针必须初始化,而初始化一旦完成,也就是存放在指针中那个地址不能再改变了。指针常量,意思是指针指向的是一个常量对象。int *const curErr;从右往...

2018-03-18 17:27:00 195

转载 c++ 快速排序

1 #include<iostream> 2 using namespace std; 3 4 void swap(int &a,int &b) 5 { 6 if(a==b) 7 return; 8 a=a+b; 9 b=a-b;10 a=a-b;11 }12 ...

2018-02-09 13:09:00 101

空空如也

空空如也

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

TA关注的人

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