自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(24)
  • 资源 (3)
  • 收藏
  • 关注

原创 2019三月PAT甲级 7-4 Structure of a Binary Tree

7-4Structure of a Binary Tree(30分)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, a binary tree can be uniquely det...

2019-08-23 18:15:57 347

原创 2019三月PAT甲级 7-2 Anniversary

7-2Anniversary(25分)Zhejiang University is about to celebrate her 122th anniversary in 2019. To prepare for the celebration, the alumni association (校友会) has gathered the ID's of all her alumni. N...

2019-08-23 18:14:26 166

原创 2019三月PAT甲级 7-1 Sexy Primes

7-1Sexy Primes(20分)Sexy primes are pairs of primes of the form (p,p+6), so-named since "sex" is the Latin word for "six". (Quoted fromhttp://mathworld.wolfram.com/SexyPrimes.html)Now given an...

2019-08-23 18:12:44 261

原创 763. Partition Labels(Greedy, two pointers)

这题用贪心很完美!非常简洁清晰 unordered_map<char, int> mp; vector<int> partitionLabels(string S) { vector<int> ret; //建立map,存放每个字符最后一次出现位置 for(int i=0; i<S.siz...

2019-04-11 16:52:25 102

原创 LeetCode141. Linked List Cycle (two pointers)

这道题用two pointers的方法也很巧妙,用一个slow pointer一次移动一步,一个fast pointer一次移动两步,如果有环,那么最终fast会和slow会和(用个简单例子比划下),如果没会和前fast或fast->next就到达了终点NULL,那么必是无环链表。这样能让空间复杂度是O(1)naive的想法是用hash table储存所有已经访问过的节点 b...

2019-04-11 11:53:43 93

原创 LeetCode283. Move Zeroes (two pointers)

如果不看tag肯定想不到可以用two pointers很快很巧妙的做出来!最开始的navie想法void moveZeroes(vector<int>& nums) { //delte all zeroes and then add back at the end int cnt = 0; for (auto it = nums.begin()...

2019-04-10 22:05:55 104

原创 LeetCode804. Unique Morse Code Words

我的想法是建立一个从单个字符到摩尔码的map,这样对所有words里单词直接映射得到相应摩尔码,再全部插入一个set中就自动去重了。(注意char到string要经过转换) int uniqueMorseRepresentations(vector&lt;string&gt;&amp; words) { vector&lt;string&gt; code = ...

2018-12-06 11:44:02 105

原创 LeetCode217. Contains Duplicate

我的办法将元素不断插入一个集合,对新元素如果集合中已存在,就返回true。(最初naive想法遍历一遍元素,对每个新元素看看该元素前面部分序列是否已存在该元素,但这样太慢了) bool containsDuplicate(vector&lt;int&gt;&amp; nums) { if(nums.size() &lt;= 1) retu...

2018-12-03 20:53:40 100

原创 LeetCode169. Majority Element

开始更多借助STL的力量。 int majorityElement(vector&lt;int&gt;&amp; nums) { vector&lt;int&gt; elem; vector&lt;int&gt; time; //elem存储元素值,time在elem相同下标位置处存储出现次数 for (auto iter = nums...

2018-12-03 20:15:29 85

原创 LeetCode485. Max Consecutive Ones

遍历一遍vector,max_seq 记录历史最长全1子串,count记录新全1子串 int findMaxConsecutiveOnes(vector&lt;int&gt;&amp; nums) { int max_seq = 0; int count = 0; for (int i = 0; i &lt; nums.siz...

2018-12-03 15:30:52 121

原创 LeetCode896. Monotonic Array

我直接写了一个判断是否单调不增或单调不减的函数,然后直接调用。 bool isIncreasing(vector&lt;int&gt;&amp; A) { for(int i = 0; i &lt; A.size()-1; ++i) if(A[i] &gt; A[i+1]) return false; ...

2018-12-03 14:54:12 105

原创 LeetCode566. Reshape the Matrix

如果要返回的matrix元素个数与原先不同,直接返回。 否则遍历一遍原matrix, 重新组装成一个新的行列数的matrix vector&lt;vector&lt;int&gt;&gt; matrixReshape(vector&lt;vector&lt;int&gt;&gt;&amp; nums, int r, int c) { int pr = nums...

2018-12-03 14:28:23 140

原创 LeetCode766. Toeplitz Matrix

思路比较简单,从第二行第二列起开始遍历, 如果matrix[row][col] != matrix[row - 1][col - 1](也即当前元素不等于起对角线上元素),就不是ToeplitzMatrix bool isToeplitzMatrix(vector&lt;vector&lt;int&gt;&gt;&amp; matrix) { int max_...

2018-12-03 13:57:11 121

原创 LeetCode867. Transpose Matrix

翻转矩阵,遍历一遍原矩阵,然后行列顺序交换着将元素插入一个新矩阵。class Solution {public: vector&lt;vector&lt;int&gt;&gt; transpose(vector&lt;vector&lt;int&gt;&gt;&amp; A) { int maxrow = A.size(); int maxcol =...

2018-12-02 10:26:13 88

原创 LeetCode561. Array Partition I

我的做法是先排序,然后取偶数位之和。因此感觉大部分都是在写归并排序。typedef size_t Rank;void merge(vector&lt;int&gt;&amp; vec, Rank first, Rank mid, Rank last) //vec[first, mid), vec[mid, last)都已拍好序,归并{ vector&lt;int&gt; A...

2018-12-02 09:51:37 87

原创 LeetCode832. Flipping an Image

题意简单,翻转图像,写个翻转每一行(一个vector)的函数,然后Image每一行调用即可。 void flipAndInvertRow(vector&lt;int&gt;&amp; vec) { size_t size = vec.size(); for (size_t i = 0; i&lt;int(size / 2); ++i) ...

2018-12-02 00:55:57 117

原创 LeetCode922. Sort Array By Parity II

这题我简单的借鉴905. Sort Array By Parity 的想法那两个vector临时存储even和odd再合并,可惜这样就慢了,88ms(43%) vector&lt;int&gt; sortArrayByParityII(vector&lt;int&gt;&amp; A) { size_t size = A.size(); vector&...

2018-12-02 00:35:12 117

原创 LeetCode905. Sort Array By Parity

我的解法,不用额外空间,p从头开始跳过偶数捕捉奇数,q从尾开始跳过奇数捕捉偶数,捕捉到就交换,知道p&lt;q不再满足。 vector&lt;int&gt; sortArrayByParity(vector&lt;int&gt;&amp; A) { int p = 0; int q = A.size() - 1; while (true...

2018-12-02 00:15:43 101

原创 pandas read_csv遇到的一个小问题

今天pd.read_csv时出了OSError: Initializing from file failed,网上给出各种原因,有文件名不对(中文或其他奇怪字符)等,但我这都没用,最后发现我的csv文件居然是write protect的,修正之后就顺利read进去了~~看样子pd.read_csv出现问题的原因真是多种多样啊...

2018-10-01 21:45:04 435

原创 LeetCode 50.Pow(x, n) python解法

题目:Implement pow(x, n).两个简化运算的地方,一是递归计算,而是提取出x^2计算class Solution: def myPow(self, x, n): """ :type x: float :type n: int :rtype: float """ if(n==0):...

2018-04-04 14:46:47 988

原创 LeetCode 258-Add Digits python 解法

258. Add Digits题目:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 ha...

2018-04-04 13:49:50 254

原创 数据结构与算法python语言实现-单链表实现

使用python实现一个简单单链表,头/尾添加/删除元素,查找满足一定条件(任意定义的条件)的元素,遍历对每个元素实行一种操作(任意定义的操作),迭代器一样的访问链表##代码部分###自定义一种错误类型class LinkedListUnderflow(ValueError): pass#定义链表节点类class LNode: def __init__(self, el...

2018-04-03 14:02:12 1595 1

原创 python入门-numpy

一.调取包import numpy as np二.数组基本操作#初始化a = np.array([1,2,3])b = np.array([[1,2,3],[4,5,6]])c = np.array([1,2,3],dtype=np.int64)    #指定数据类型的初始化#像list那样索引a[0],切片type(a)    #numpy.ndarray 数组a的类型a.dtype    #数...

2018-03-23 10:56:05 326

原创 python入门-容器

1.list 列表# 初始化列表li = [1, 2, 3, 'abc', 4.5, [2, 3, 4], {1:'one'}]    #可以是任意元素#还有元组比如 li=(1,2,3) 只能写不能读# 获取长度print(len(li))print('') #空一行# 根据索引读写print(li[0])print(li[-1])#-1索引表示倒数第一个(其实是表示len(li)-1)# 添加...

2018-03-22 23:04:47 319

TensorFlow For Machine Intelligence Stanford Textbook

This TensorFlow book introduces the framework and the underlying machine learning concepts that are important to harness machine intelligence.

2018-03-03

Fundamentals of Deep Learning(2017) Stanford textbook

This booked is aimed an audience with a basic operating understanding of calculus, matrices, and Python programming. Approaching this material without this back‐ ground is possible, but likely to be more challenging. Background in linear algebra may also be helpful in navigating certain sections of mathematical exposition. By the end of the book, we hope that our readers will be left with an intuition for how to approach problems using deep learning, the historical context for modern deep learning approaches, and a familiarity with implementing deep learning algorithms using the TensorFlow open source library

2018-03-03

MATLAB deep learning

This book is written for two kinds of readers. The first type of reader is one who plans to study Deep Learning in a systematic approach for further research and development. This reader should read all the content from the beginning to end. The example code will be especially helpful for further understanding the concepts. A good deal of effort has been made to construct adequate examples and implement them. The code examples are constructed to be easy to read and understand. They are written in MATLAB for better legibility. There is no better programming language than MATLAB at being able to handle the matrices of Deep Learning in a simple and intuitive manner. The example code uses only basic functions and grammar, so that even those who are not familiar with MATLAB can easily understand the concepts. For those who are familiar with programming, the example code may be easier to understand than the text of this book. The other kind of reader is one who wants more in-depth information about Deep Learning than what can be obtained from magazines or newspapers, yet doesn’t want to study formally. These readers can skip the example code and briefly go over the explanations of the concepts. Such readers may especially want to skip the learning rules of the neural network.

2018-03-03

空空如也

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

TA关注的人

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