自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Curiouszhou's Blog

学习心得

  • 博客(23)
  • 收藏
  • 关注

原创 字符串abcdef, 有条件的最长子序列

题目描述:字符串T包含abcdef, T < 300005a只能在ce前面,c只能在e前面b只能在df前面,d只能在f前面问 最长子序列多长?example:afcaba = 4;bbeeae = 5;题解分成两个字符串算总长,一个只包含ace,一个只包含bdf。以a结尾的只能从a转移过来,c可以从ac转移过来,e可以从ace转移过来。复杂度O(n)。//// Created by ironzhou on 2020/8/3.// 字符串T包含abcdef, T < 300

2020-08-03 21:19:08 654

原创 11.二进制中1的个数

二进制中1的个数题目描述输入一个整数,输出该数32位二进制表示中1的个数。其中负数用补码表示题解不能将这个数右移,负数的话首位会补1。可以用0x01左移。也可以用val & (val - 1)判断。class Solution {public: int NumberOf1(int n) { int ans = 0; while(n != 0){ ans++; n = n & (n-1

2020-07-17 22:10:39 109

原创 10.矩形覆盖

矩形覆盖题目描述我们可以用21的小矩形横着或者竖着去覆盖更大的矩形。请问用n个21的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法?题解动规,dp[n] = dp[n-1]+dp[n-2], dp[1] = 1。class Solution {public: int rectCover(int number) { if(number == 0 || number == 1) return number; int a = 0, b = 1, c;

2020-07-13 17:24:49 132

原创 9.变态跳台阶

变态跳台阶题目描述一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。题解f(n)=f(n-1)+f(n-2)+……f(1)f(n-1)=f(n-2)+……f(1)两式相减得f(n)=2f(n-1)class Solution {public: int jumpFloorII(int number) { int &n = number; if(n == 0 || n == 1) retu

2020-07-13 17:15:31 121

原创 8.跳台阶

跳台阶题目描述一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果)类似Fibonacciclass Solution {public: int jumpFloor(int number) { vector<int> dp(1000,0); dp[1] = 1; dp[2] = 2; for(int i = 3; i <= number ;i++)

2020-07-13 16:46:37 63

原创 7.斐波那契数列

斐波那契数列题目描述大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0,第1项是1)。记忆化搜索class Solution {public: int dfs(int n, vector<int>& dp){ if(n == 0 || n == 1) return n; if(dp[n] != -1) return dp[n]; return dp[n] = dfs(n-1,

2020-07-13 16:30:54 112 1

原创 6.旋转数组的最小数字

旋转数组的最小数字题目描述把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。题解这题可以看作两个非递减数组拼接,右边<=左边,寻找中间分界线。二分查找拐点arr[mid]<arr[mid-1]。二分比较的重点是,只能和最右端元素比较。如果和最左端比较,例如4,5,

2020-07-13 16:13:06 62

原创 LeetCode 31. Next Permutation

LeetCode 31. Next PermutationImplement next permutation, which rearranges numbers into thelexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as thelowest possible order (ie, sorted in ascend

2020-07-08 15:28:42 77

原创 3.从头到尾输出链表

从头到尾输出链表题目描述输入一个链表,按链表从尾到头的顺序返回一个ArrayList。思路1.反转链表2.递归3.栈C++ 反转链表class Solution {public: vector<int> printListFromTailToHead(ListNode* head) { ListNode* tail = NULL; while(head){ ListNode *nex = head->next

2020-07-07 17:03:10 179

原创 2.替换空格

替换空格题目描述请实现一个函数,将一个字符串中的每个空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。思路从右往左复制。class Solution {public: void replaceSpace(char *str,int length) { if(str == nullptr || length <= 0 ) return; int cnt = 0; for(

2020-07-07 15:54:51 59

原创 1.二维数组中的查找

二维数组中的查找题目描述在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。思路可以从右上角和左下角两个特殊位置开始搜索。对右上角元素,左边都比它小,下边都比它大。左下角类似。所以是O(m+n)。C++:class Solution {public: bool Find(int target, vector<vector<int>

2020-07-07 11:22:22 131

原创 LeetCode 1248. Count Number of Nice Subarrays

LeetCode 1248. Count Number of Nice SubarraysGiven an array of integers nums and an integer k. A subarray is called nice if there are k odd numbers on it.Return the number of nice sub-arrays.Examp...

2019-11-04 02:56:03 628

原创 Leetcode 1235. Maximum Profit in Job Scheduling(Hard)

We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i].You’re given the startTime , endTime and profit arrays, you need to output th...

2019-10-21 03:15:15 275

原创 LeetCode 1223. Dice Roll Simulation(dp+记忆化搜索)

LeetCode 1223. Dice Roll SimulationA die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than r...

2019-10-14 00:25:22 806

原创 LeetCode 76. Minimum Window Substring(Hard)

LeetCode 76. Minimum Window Substring(Hard)Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).Example:Input: S = “ADOBECODE...

2019-10-11 10:18:10 130

原创 LeetCode 206. Reverse Linked List

LeetCode 206. Reverse Linked ListReverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed ...

2019-10-11 05:28:25 89

原创 LeetCode 23. Merge k Sorted Lists

LeetCode 23. Merge k Sorted ListsMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[1->4->5,1->3->4,2->6]Output: ...

2019-10-11 01:10:01 90

原创 LeetCode 42. Trapping Rain Water(Hard)

LeetCode 42. Trapping Rain WaterGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.The above el...

2019-10-10 13:54:50 86

原创 Leetcode 15 3sum

Leetcode 15 3sumTwo-Pointer O(n^2)Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.N...

2019-10-09 06:46:10 77

原创 Leetcode146 LRU Cache

Leetcode146 LRU CacheDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.get(key) - Get the value (will always be posi...

2019-10-08 23:15:44 79

转载 什么是张量(Tensor)

作者:知乎用户链接:什么是张量(tensor)来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。    对于大部分已经熟练的数学和物理工作者, 这实在是一个极为基础的问题. 但这个问题在我刚接触张量时也困扰了我很久. 张量的那么多定义, 究竟哪些是对的? (显然都是对的. ) 它们的关系是什么? 我尽可能简单地用我自己的...

2019-05-08 14:42:00 1625

转载 线性代数的本质--对线性空间、向量和矩阵的直觉描述

看到一篇讲线性代数非常通俗易懂的好文,记录下来方便自己反复体会。原文链接:线性代数的本质–对线性空间、向量和矩阵的直觉描述作者:JustDoIT:博客rss订阅地址在网上看到的一篇文章,看了以后感触颇深。线性代数课程,无论你从行列式入手还是直接从矩阵入手,从一开始就充斥着莫名其妙。比如说,在全国一般工科院系教学中应用最广泛的同济线性代数教材(现在到了第四版),一上来就介绍逆序数这个古怪...

2019-05-07 17:52:02 1677 2

原创 Ubuntu18.04下安装Caffe(CPU)心得

卒!作为一个实习生,进公司地一个实习任务是配置Caffe环境,What?Tensorflow不好嘛!抗议无果。。。好吧,干就完事了。python安装就不说了,用的是Anaconda-3.7,安装很简单也很好用,但是Anaconda自带的Protobuf与Caffe不兼容...

2019-05-06 17:16:35 2271

空空如也

空空如也

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

TA关注的人

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