自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 257. 二叉树的所有路径

这里要注意下,之所以不在else里加答案,主要是因为,会重复if里的操作,还有为什么只要在if里加答案,是因为,每次if迭代推进栈的实际上是当前点的下一个点路径,这导致了,如果不在if里添加答案,当当前点被废弃时,它的路径path也会被废弃,这导致了尽管else可以遍历到每一个节点,但它对应的路径却已经在if中被消掉了。//节点和路径同时出栈。//若找到叶子节点。//节点和路径同时入栈。257.二叉树的所有路径。...

2022-07-25 11:54:33 158 1

原创 222. 完全二叉树的节点个数

while处是logn级别实际上可以用二进制的移位进行理解,每一层树都是其实都是类似于二进制码0111,0011,0001,分别代表三层树,两层树,一层树,而从0001到0011,因为0011可以看作0100-1,当舍去1,就变成了0100,也就是0001先左移了2位,而这个移位实际上就是log(0100)等于2约等于log(0011),而0011等于第二层包括第一层全部的节点数量。这两种不算完全二叉树。...

2022-07-23 12:15:23 182

原创 904. Fruit Into Baskets

​​​​​​904. Fruit Into Baskets题目如上,代码如下第一种class Solution {public: int totalFruit(vector<int>& fruits) { int ans = 0 ,i = 0; map<int, int> count; for (int j = 0; j < fruits.size(); ++j) { cou

2022-05-01 15:28:50 942

原创 844. Backspace String Compare(双指针法)

844. Backspace String Compare代码如下class Solution {public: bool backspaceCompare(string s, string t) { int first=s.length()-1,second=t.length()-1; int space_s=0,space_t=0; while(first>=0 || second>=0){ whil

2022-04-18 12:13:13 190

原创 283. Move Zeroes

283. Move Zeroes题目如上,下面是代码class Solution {public: void moveZeroes(vector<int>& nums) { int first=0,second=0,size = nums.size(); for(int first = 0 ;first<size;first++){ if(nums[first]!=0){ n

2022-04-18 10:28:55 71

原创 26. Remove Duplicates from Sorted Array

26. Remove Duplicates from Sorted Array题目如上 ,然后我这里有两种办法,第一种,利用一个标记数组记录已经有的数字,不过因为题目的数字取值范围有负数,所以要将题目中的数组成员全部加1000,保证没有负数,不过赋值的时候不需要管,代码如下class Solution {public: int removeDuplicates(vector<int>& nums) { int first=0,second=0;

2022-04-17 10:04:55 132

原创 367. Valid Perfect Square

​​​​​​367. Valid Perfect Squarehttps://leetcode-cn.com/problems/valid-perfect-square/题目在上面,我已经懒得转中文了,所以就这样吧,给代码如下class Solution {public: bool isPerfectSquare(int num) { int r = num ; int l = 0; while(r>=l){

2022-04-16 10:00:50 137

原创 C++学习笔记(至4.15)

2022.3.22类成员,类的组合,友元常对象只能调用它的常成员函数,而不能调用普通的成员#include<iostream> //例3.40-2using namespace std;class Sample{ private: int n; public: int m; Sample(int i,int j){ m=i; n=j; } void setvalue(int i){ n=i; } void disply() {cout<

2022-04-16 09:52:45 111

原创 69. x 的平方根

69. x 的平方根题目如上,我只会二分,牛顿迭代法没学过,所以只给二分的解法,但是二分法解这个的思路又很简单,所以我不做补充class Solution {public: int mySqrt(int x) { int r = x ; int l = 0; while(r>=l){ int mid = r + (l-r)/2; if(mid*mid>x){ .

2022-04-16 09:49:43 116

原创 34. Find First and Last Position of Element in Sorted Array

34. Find First and Last Position of Element in Sorted Array题目链接如上先给代码class Solution {public: vector<int> searchRange(vector<int>& nums, int target) { int left = searchleft(nums,target); int right = searchright(nu

2022-04-15 17:14:51 193

原创 JDBC总合笔记

2022.3.22JDBC入门 2-2—–>3-1我用的软件是navicat,然后用的时候发现,如果你想要在这个软件中访问数据库,那你访问的时候它数据库本身就已经打开了(cmd里),不然链接无效报错.如何查询版本号在cmd里mysql -V注意,V小写貌似不太行如何下载jdbc的教程https://blog.csdn.net/pan_junbiao/article/details/86626741注意下,进入mysql connector时 , 那个是自己勾选的,有

2022-03-28 11:18:03 66

原创 JDBC学习笔记

2022.3.22JDBC入门 2-2—–>3-1我用的软件是navicat,然后用的时候发现,如果你想要在这个软件中访问数据库,那你访问的时候它数据库本身就已经打开了(cmd里),不然链接无效报错.如何查询版本号在cmd里mysql -V注意,V小写貌似不太行如何下载jdbc的教程https://blog.csdn.net/pan_junbiao/article/details/86626741注意下,进入mysql connector时 , 那个是自己勾选的,有

2022-03-22 23:06:00 696

原创 C++学习笔记2022.3.22

2022.3.22类成员,类的组合,友元常对象只能调用它的常成员函数,而不能调用普通的成员#include<iostream> //例3.40-2using namespace std;class Sample{ private: int n; public: int m; Sample(int i,int j){ m=i; n=j; } void setvalue(int i){ n=i; } void disply() {cout<

2022-03-22 18:08:39 1143

原创 idea的一些常用快捷键

快捷键面板查询ctrl + insert + (fn)–> 构造器,get,set方法等ctrl+alt +s –>settings面板ctrl +shift +F/R —>全局查找,全局修改(文本)ctrl+f/r—>当前文件查找(文本)ctrl+shift +n 文件查找面板alt+insert +(fn) 快速生成面板ctrl+shift +a —>find action(这个是最重要的,因为其他快捷键都可以直接通过这个找出来,只要你记得英文)代码快

2022-03-21 22:25:38 631

原创 有关于idea快捷键冲突的问题

常用的快捷键冲突网上都有,所以我分享一个解决这类问题的思路,首先,快捷键冲突主要来自于软件的本身设置的快捷键,那么按照这个思路下去,只要将全部软件关掉就可以直接使用idea了所以我解决它直接依靠了重启,然后我只有几个程序在运行,我自己的问题是ctrl+shift+a被占用了,所以我重启后试了下idea,发现还是不行,但是此时我运行的程序已经很少了,所以我将每一个程序的设置点开,把它们和这个快捷键有关的设置全删了,然后我就成了....

2022-03-21 19:59:44 795

原创 2020.3.4

2022.3.4类与对象的基本性质#include<iostream>#include<vector>#include<algorithm>#include<cmath>#include<stack>#pragma warning (disable:4996)#include<queue>using namespace std;class A { double a; double b;public : v

2022-03-04 17:58:13 112

原创 D. Kilani and the Game

Problem - 1105D - Codeforceshttps://codeforces.com/problemset/problem/1105/DD. Kilani and the Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKilani is playing a game with his fr

2022-02-21 21:18:23 125

原创 on java8学习笔记2022.2.19-2022.2.20

2022.2.19第十章 接口如果一个类并不需要包含抽象方法,但同时还想阻止对它的任何实例化,这时将其定义为抽象类就很有用了。接口和抽象类之间最显著的区别可能是两者的惯用方式。接口通常暗示“类的类型”或作为形容词来使用,例如Runnable或Serializable,而抽象类通常是类层次结构的一部分,并且是“事物的类型”,例如String或Instrument。接口也可以包含字段,但这些字段是隐式的static和final。接口(该接口的修饰符是默认)如果只有包访问权限

2022-02-20 23:23:07 365

原创 on java 8 学习笔记 2022.2.17-2022.2.18

2022.2.17问题正如你在第8章会看到的,当引入继承时,通过继承而来的类(子类)可以访问父类的protected成员以及public成员(但不能访问private成员)。只有当两个类在同一个包中时,它才可以访问父类的包访问权限成员。但现在不必担心继承和protected。7.2.1没看懂这句话想表达什么答:意思很简单,就是强调默认包的访问权限然而,仅仅因为一个对象的引用在类中是private的,并不意味着其他对象不能拥有对同一个对象的public引用。(请参阅进阶卷第2章了解别名

2022-02-18 22:08:52 250

原创 Mysql:Access denied for user ‘root@localhost‘ (using password:NO)

今天按照康老师讲的,装完打算登录,结果就给我报了题目的那个错误,然后我查了下,那个命令应该是这个mysql -uroot -p你输入这个,他会在第二行让你输密码

2022-02-17 16:13:41 388

原创 on java 8 学习笔记 2022.2.16

2022.2.16问题其实我感觉引用计数的方法不只书中提到的这种问题吧,难道不会有对象被误删的情况吗?答:不会,因为这种方法就是参考了只要有引用,它就是有效对象的路子,而只要引用大于0,那它就是有效对象,这种初始化方法简单明了,但有个限制:类InitialValues的每个对象都会有相同的初始值。有时候这正是你想要的,但有时你可能需要更大的灵活性。看不懂,啥意思?我觉得已经挺灵活的了答:看了6.7,感觉用构造器初始化不就是我们正常的操作吗?秀了我一脸懵逼,这有啥好灵不灵活的/

2022-02-16 23:17:37 388

原创 Phillip and Trains CodeForces - 585B (DFS)

Problem - 585B - Codeforceshttps://codeforces.com/problemset/problem/585/BThe mobile application store has a new game called "Subway Roller".The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. T

2022-02-16 11:19:24 214

原创 on java 8学习笔记

2022.2.15第三章new 关键字创建出来的对象位于堆中,而基本数据类型则会被创建在栈中{ int x = 12; { int x = 96; // 语法错误 }}这种写法在java中是错的,但在c++里是允许的字段(有时叫作“数据成员”)和方法(有时叫作“成员函数”)如果变量作为类成员而没被初始化过就会被java默认初始化,当时如果变量是类的方法中的,那么就不会被默认初始化public class test { public d

2022-02-15 23:12:56 407 2

原创 Kefa and Park CodeForces - 580C

Problem - 580C - CodeforcesKefa decided to celebrate his first big salary by going to the restaurant.He lives by an unusual park. The park is a rooted tree consisting ofnvertices with the root at vertex1. Vertex1also contains Kefa's house. Unfortu...

2022-02-14 00:22:28 178

原创 2022.2.13java学习笔记

2022.2.12其他Object[] args表示的是命令行参数2022.2.13on java 8 (摘录)对Class对象使用泛型语法时,newInstance()会返回对象的确切类型,而不仅仅是简单的Object,就像在ToyTest.java示例中看到的那样。但它也会受到一些限制:// reflection/toys/GenericToyTest.java// 测试Class类// {java reflection.toys.GenericToyTest}package

2022-02-14 00:18:07 151

原创 D - Fox And Two Dots CodeForces - 510B

Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of sizen × mcells, like this:Each cell contains a dot that has some color. We will use different uppercase Latin characters to express different colors..

2022-02-12 11:40:27 251

原创 java学习笔记 2022.2.11

2022.2.11on java 8 摘录(反射)加载。这是由类加载器执行的。该步骤会先找到字节码(通常在类路径中的磁盘上,但也不一定),然后从这些字节码中创建一个Class对象。链接。链接阶段会验证类中的字节码,为静态字段分配存储空间,并在必要时解析该类对其他类的所有引用。初始化。如果有基类的话,会先初始化基类,执行静态初始化器和静态初始化块。初始化被延迟到首次引用静态方法(构造器是隐式静态的)或非常量静态字段时:// reflection/ClassInitialization

2022-02-11 23:29:32 212

原创 Belted Rooms CodeForces - 1428B

Problem - 1428B - Codeforceshttps://codeforces.com/problemset/problem/1428/BIn the snake exhibition, there arennrooms (numbered00ton - 1n−1) arranged in a circle, with a snake in each room. The rooms are connected bynnconveyor belts, and theii-th...

2022-02-11 16:57:26 567

原创 java学习笔记2022.2.11

on java 8 摘录(反射)面向对象编程的一个基本目标就是,让编写的代码只操纵基类(本例中为Shape)的引用Shape接口中的方法draw()是可以动态绑定的,因此客户程序员可以通过泛化的Shape引用来调用具体的draw()方法。在所有子类中,draw()都被重写,并且因为它是一个动态绑定的方法,即使通过泛化的Shape引用来调用它,也会产生正确的行为。这就是多态。abstract class Shape { void draw() { System.out.prin

2022-02-11 10:40:41 499

原创 2022.2.3Java学习笔记

2022.2.3FIleInputStream 与FileOutPutStreamimport java.io.FileInputStream;import java.io.FileOutputStream;public class one { public static void main(String[] args){ FileOutputStream out; FileInputStream in; try{

2022-02-09 20:57:02 311

原创 2022.2.3 java学习笔记

2022.2.2问题import java.io.File;import java.io.IOException;public class one { public static void main(String[] args){ File file = new File("E:\\test"); File file1 = new File(file,"one"); System.out.println(file1.isDirectory

2022-02-03 17:23:26 1024

原创 java第四周学习笔记

文章目录2022.1.25Map2022.1.26排序Comparator接口Comparable接口其他DescriptionSyntaxParametersReturn Value2022.1.27泛型其他2022.1.28泛型线程Thread其他2022.1.29线程2022.1.30on java 8读书笔记(摘录)线程2022.1.25Map有关于如何处理重复数据输入以及错误信息输入while(i<3){ String id = input.next();

2022-02-01 17:16:59 85

原创 java 学习笔记2022.1.26

排序Comparator接口有关于Comparator接口,这个接口一般是作为参数放在排序方法里的,最开始我也觉得挺别扭的,后面想了想,这也主要是因为在java中,单独的一个函数不能存在,所以设计了这样的一个接口,让我们能通过类来间接调用函数public class test { public static void main(String[] args) { Cat a= new Cat("b",311,"fjkdjfdkd"); Cat b= new C

2022-01-27 18:45:14 371

原创 Rumor CodeForces - 893C

Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it.Now he tries

2022-01-25 21:40:56 101

原创 Badge CodeForces - 1020B

Badge - CodeForces 1020B - Virtual Judgehttps://vjudge.net/problem/CodeForces-1020BIn Summer Informatics School, if a student doesn't behave well, teachers make a hole in his badge. And today one of the teachers caught a group ofnnstudents doing yet an..

2022-01-25 18:48:55 147

原创 第三周学习笔记

文章目录2022.1.15其他2022.1.16问题集合Map其他2022.1.20问题集合Map其他2022.1.21问题集合Map2022.1.23思考题查阅时一些有趣的信息其他查阅时一些有趣的信息其他2022.1.15其他public class PokeDemo { public static void main(String[] args ){ try { Pokemon a1 = PokemonManage.getPokemon("Sur

2022-01-23 23:26:15 51

原创 Mike and Feet CodeForces - 547B

https://vjudge.net/problem/CodeForces-547Bhttps://vjudge.net/problem/CodeForces-547BMike is the president of country What-The-Fatherland. There arenbears living in this country besides Mike. All of them are standing in a line and they are numbered from..

2022-01-23 20:09:15 76

原创 Mike and Feet CodeForces - 547B

Mike and Feet - CodeForces 547B - Virtual Judgehttps://vjudge.net/problem/CodeForces-547BMike is the president of country What-The-Fatherland. There arenbears living in this country besides Mike. All of them are standing in a line and they are numbered..

2022-01-22 10:13:23 325

原创 Poisoned Dagger CodeForces - 1613C

Poisoned Dagger - CodeForces 1613C - Virtual Judgehttps://vjudge.net/problem/CodeForces-1613CMonocarp is playing yet another computer game. In this game, his character has to kill a dragon. The battle with the dragon lasts100^{500}100500seconds, during..

2022-01-20 16:06:58 287

原创 C - Bad Sequence

Petya's friends made him a birthday present — a bracket sequence. Petya was quite disappointed with his gift, because he dreamed of correct bracket sequence, yet he told his friends nothing about his dreams and decided to fix present himself.To make ever

2022-01-20 09:05:48 91

空空如也

空空如也

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

TA关注的人

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