摘要: 1 #include <iostream> 2 #include<string> 3 using namespace std; 4 5 class Point { 6 public: 7 Point(int a, int b) :x(a), y(b) {}; 8 //Point(Point& p) 阅读全文
posted @ 2020-01-05 16:34 Chenjin123 阅读(3036) 评论(0) 推荐(0) 编辑
摘要: public: 公有继承时,对基类的公有成员和保护成员的访问属性不变,派生类的新增成员可以访问基类的公有成员和保护成员,但是访问不了基类的私有成员。派生类的对象只能访问派生类的公有成员(包括继承的公有成员),访问不了保护成员和私有成员。 protected: 保护继承中,基类的公有成员和保护成员被派 阅读全文
posted @ 2020-01-05 14:01 Chenjin123 阅读(1986) 评论(0) 推荐(1) 编辑
摘要: 思路: 1.先对数组排序 2.遍历第一遍求最小绝对值差 3.遍历第二遍填充最小绝对值差的元素对 1 class Solution { 2 public List<List<Integer>> minimumAbsDifference(int[] arr) { 3 int minAbs=Integer 阅读全文
posted @ 2020-01-03 19:45 Chenjin123 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 题意:从给定数组中提取出最长的等差序列(不一定连续),返回它的长度 暴力超时: 1 class Solution { 2 public int longestSubsequence(int[] arr, int difference) { 3 int res=1; 4 for(int i=0;i<a 阅读全文
posted @ 2020-01-03 19:32 Chenjin123 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 #include<vector> 3 #include<queue> 4 #include<map> 5 #include<set> 6 #include<cmath> 7 #include<cstdio> 8 #include<cstdlib> 9 # 阅读全文
posted @ 2019-12-26 22:59 Chenjin123 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 #include<vector> 3 #include<queue> 4 #include<map> 5 #include<set> 6 #include<cmath> 7 #include<cstdio> 8 #include<cstdlib> 9 # 阅读全文
posted @ 2019-12-26 16:13 Chenjin123 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 题意: 输出子序列的最大和以及子序列的首尾元素.如果存在多个最大和子序列取位置最靠左的那个.如果序列元素全<0,和为0,输出给定序列的首尾元素. 1 #include<iostream> 2 #include<vector> 3 #include<queue> 4 #include<map> 5 # 阅读全文
posted @ 2019-12-26 15:50 Chenjin123 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 题意: 找到最早进门的人和最晚出门的人.字符串比较即可. 模拟: 1 #include<iostream> 2 #include<vector> 3 #include<queue> 4 #include<map> 5 #include<set> 6 #include<cmath> 7 #includ 阅读全文
posted @ 2019-12-26 15:10 Chenjin123 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 题目很简单,但是要注意输入的范围是10^100,int,long long都不能存,只能创建一个字符串. 1 #include<iostream> 2 #include<vector> 3 #include<queue> 4 #include<map> 5 #include<set> 6 #incl 阅读全文
posted @ 2019-12-26 14:52 Chenjin123 阅读(148) 评论(0) 推荐(0) 编辑
摘要: bfs:记录层序 1 #include<iostream> 2 #include<vector> 3 #include<queue> 4 #include<map> 5 #include<set> 6 #include<cmath> 7 #include<cstdio> 8 #include<cst 阅读全文
posted @ 2019-12-26 14:28 Chenjin123 阅读(184) 评论(0) 推荐(0) 编辑