- 博客(37)
- 收藏
- 关注
原创 python学习1
介绍python基础学习的八个要素:#1:数据类型python提供了多种内置数据类型,首先关注int类型与str类型:1、int类型:表示整数(正、负),且python所能表示的整数大小只受限于机器内存,而非固定数量的字节数。2、str类型:表示字符串(unicode字符序列,不局限于ASCII字符),可使用单引号/双引号封装。a.python使用[]来存取字符串等序列中的某一...
2019-11-21 19:19:37 156
原创 最小时间差
class Solution {public: int findMinDifference(vector<string>& timePoints) { vector<int>k; int len=timePoints.size(); //化string为数字,且统一单位为分钟; for(int ...
2019-08-05 17:17:15 261
原创 现在输入一个公司的所有员工信息,以及单个员工id,返回这个员工和他所有下属的重要度之和。
/*// Employee infoclass Employee {public: // It's the unique ID of each node. // unique id of this employee int id; // the importance value of this employee int importance; ...
2019-08-01 21:41:11 240
原创 现在输入一个公司的所有员工信息,以及单个员工id,返回这个员工和他所有下属的重要度之和。
/*// Employee infoclass Employee {public: // It's the unique ID of each node. // unique id of this employee int id; // the importance value of this employee int importance; ...
2019-08-01 15:36:57 282
原创 在MATLAB中,有一个非常有用的函数 reshape,它可以将一个矩阵重塑为另一个大小不同的新矩阵,但保留其原始数据。
class Solution {public: vector<vector<int>> matrixReshape(vector<vector<int>>& nums, int r, int c) { int w=nums.size(); int h=nums[0].size(); ...
2019-08-01 14:41:15 1069
原创 问在有限的操作数范围内,能够得到最大连续的相同字符的子串的长度是多少。
#include<iostream>#include<string>#include<vector>using namespace std;int n,m;string str;//全局变量;int change(char ch){ vector<int>loc; for(int i=0;i<n;i++){if(...
2019-07-31 15:24:44 283
原创 字节跳动-求如果打完最后的 (n-k) 场比赛,有没有可能三只球队的分数打平。
#include<iostream>using namespace std;int main(){ int t; cin>>t; for(int i=0;i<t;i++){ long long n,k,d1,d2; cin>>n>>k>>d1>>d2;...
2019-07-30 22:26:53 183
原创 简单错误记录-开发一个简单错误记录功能小模块,能够记录出错的代码所在的文件名称和行号。
#include<iostream>#include<string>#include<vector>using namespace std;struct rec{ public: string pathway; string filename; int line; int num;};int main(){...
2019-07-30 17:06:55 1041
原创 华为[编程题]最高分是多少-牛客网
#include<iostream>#include<vector>using namespace std;int main(){ int n,m; while(cin>>n>>m){ vector<int>stu(n); for(int i=0;i<n;i++){ c...
2019-07-30 15:32:44 488
原创 矩阵转置
class Solution {public: vector<vector<int>> transpose(vector<vector<int>>& A) { int w=A.size();//原始二维向量的行; int h=A[0].size();//原始二维向量的列;...
2019-07-29 19:57:11 144
原创 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。
class Solution {public: vector<int> twoSum(vector<int>& nums, int target) { vector<int>result; for(int i=0;i!=nums.size();i++){//遍历数组每一个元素; int j=i+1;...
2019-07-29 19:25:00 1519
原创 打乱一个没有重复元素的数组。
class Solution {public: vector<int>temp; Solution(vector<int>& nums) { temp=nums;//将给定的数组存起来,以备后续的reset; } /** Resets the array to its original c...
2019-07-29 17:06:28 463
原创 函数要返回数组 A 中所有为等差数组的子数组个数。
class Solution {public: int numberOfArithmeticSlices(vector<int>& A) { int len=A.size(); if(len<3){return 0;}//若是数组个数<3,则没有; int count=0;//每次增加的等差数列个数...
2019-07-29 16:53:45 603
原创 LeetCode 670: 最大交换
class Solution {public: int maximumSwap(int num) { if(num<=10)return num;//若是<10,则直接弹出该值,无需操作; vector<int> res; while(num){res.push_back(num%...
2019-07-28 22:15:18 82
原创 3的幂
class Solution {public: bool isPowerOfThree(int n) { if(!n) return false; while(n%3==0){n /= 3;} if(n==1) return true; else return false; }};思路;可...
2019-07-28 20:35:00 65
原创 LeetCode 跳跃游戏
class Solution {public: bool canJump(vector<int>& nums) { int n=1; for(int i=nums.size()-2;i>=0;i--){//从倒数第二个位置开始遍历; if(nums[i]>=n){//若是在这个位置的值大于等于n,则表...
2019-07-28 20:23:17 70
原创 二叉树最近公共祖先
class Solution {public: TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) { if(root==NULL || root->val==p->val || root->val==q->val) re...
2019-07-27 20:13:49 117
原创 LeetCode 235. 二叉搜索树的最近公共祖先
class Solution { public: TreeNode* result=NULL; TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) { if(root==NULL) return root; else...
2019-07-27 19:22:36 48
原创 最长回文子串
class Solution {public: string str=""; int maxlen=0;//全局变量 string longestPalindrome(string s) { if(s.length()<=1 )return s; for(int i=0;i<s.length()-1;i+...
2019-07-26 19:18:58 62
原创 给定一个链表,判断链表中是否有环。
class Solution {public: bool hasCycle(ListNode *head) { if(head==NULL)return false; ListNode *fast,*slow;//快慢指针; fast=head; slow=head; //有环就不会出现NULL的情况;...
2019-07-26 18:16:07 147
原创 leetcode-找出只出现一次的那两个元素。
class Solution {public: vector<int> singleNumber(vector<int>& nums) { vector<int>single; sort(nums.begin(),nums.end()); int i=0; while(i<n...
2019-07-25 22:05:26 206
原创 求交集
class Solution {public: vector<int> intersect(vector<int>& nums1, vector<int>& nums2) { sort(nums1.begin(),nums1.end()); sort(nums2.begin(),nums2.end());...
2019-07-25 21:52:07 84
原创 LeetCode 80 删除排序数组中的重复项
class Solution {public: int removeDuplicates(vector<int>& nums) { if(nums.size()==0)return 0; int i=0; int j=1; int temp=0; for(;j!= nums.size();...
2019-07-24 20:52:37 62
原创 平方根
class Solution {public: int mySqrt(int x) { if(x==0 || x==1){return x;} else return (int)sqrt(x); } int sqrtw(int x){ int b=x/2;...
2019-07-24 18:55:44 98
原创 LeetCode 给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数。
class Solution {public: vector<int> twoSum(vector<int>& numbers, int target) { vector<int>index; int start=0; int end=numbers.size()-1; while(...
2019-07-16 19:42:25 1339
原创 LeetCode 键盘行
class Solution {public: vector<string> findWords(vector<string>& words) { vector<string> res; //定义一个string类型的vector unordered_set<char> a{'q','w','e',...
2019-07-16 12:53:53 64
原创 LeetCode 最长同值路径
/*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode(int x) : val(x), left(NULL), right(NULL) {}* };*/ ...
2019-07-11 20:02:56 72
原创 寻找两个有序数组的中位数
class Solution {public: double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) { double midnum; int k=nums1.size()+nums2.size(); for(int...
2019-07-05 21:39:51 91
原创 Pow(x,n)-LeetCode
class Solution {public: double myPow(double x, int n) { double sum=1.00000; if(n==0)return 1; if(n==1)return x; for(int i=n;i!=0;i=i/2){ if(i%2!=0){sum...
2019-07-05 21:38:33 116
原创 H指数- LeetCode
class Solution {public: int hIndex(vector<int>& citations) { int size=citations.size(); if( size == 0 ) return 0; sort(citations.begin(),citations.end(),greater&...
2019-07-05 21:36:29 159
原创 常用小tips
Tips:电脑无法复制粘贴时,查阅任务管理器中rdpclip.exe进程,结束该exe并重启exe。 注册谷歌邮箱时,若出现最后电话号码无法验证的情况,使用qq邮箱APP,进入添加邮箱界面注册谷歌邮箱,一定ok,163邮箱不行。 若电脑在打开PPT时出现需要修复,但是点击修复or选择不修复都无法正常打开,则可按照以下操作:新建一个ppt-文件-选项-信任中心-信任中心设置-受保护的视图-取...
2018-07-20 13:56:48 1195
原创 视频关键基础点
在学习视频处理时,首先需要搞明白的关键基础总结:1、视觉系统:感光细胞--锥状细胞:亮光下作用,感受彩色色调,有3中类型,峰值分别位于红色(570nm附近)、 绿 色 (535nm附近)和蓝色(445nm附近)波长; ...
2018-03-21 22:04:27 183
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人