自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 PyG笔记

坑就是越踩越多,越填越少。

2022-10-29 14:08:02 383 1

原创 PyCharm更改背景颜色

pycharm 2022.2 自定义背景颜色

2022-10-27 14:59:48 816 1

原创 PyTorch中创建Tensor的几种常用函数

import torchmean = torch.tensor([10,20,30],dtype=torch.float32)a = torch.normal(mean, 1.0) #均值分别为[10,20,30], std=1, size与均值保持一致b = torch.randn(2,3) #标准正态分布 mean=0, std=1, size=(2,3)c = torch.rand(1,3) #区间[0,1)随机采样,size=(1,3)d = torch.randint(5,10,(1.

2020-12-01 18:45:53 331 1

原创 解决matlab2019b中文乱码问题

当系统语言和matlab语言都是英文的时候,打开带有中文注释的.m文件会产生乱码。解决方法:在bin目录下用文本编辑器打开lcdata.xml,将原末尾的:<!-- </locale> --></lcdata>增加三行代码,改为:<!-- </locale> --><codeset> <encoding name="windows-1252" jvm_encoding="GB2

2020-07-05 05:00:42 6634 4

原创 如何找到win10锁屏界面壁纸

(1)win+r 调出运行 ,粘贴运行下列字符%localappdata%\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets(2)在打开的文件夹中新建一个txt文档,键入如下字符ren *.* *.jpg(3)保存,重命名为 "批量修改文件后缀名.bat"(4)...

2020-03-12 00:00:59 506 1

原创 CodingBat | make_bricks

链接:Make bricks问题思路:先尽可能多地使用大的,再使用小的1)用了多少块大的:min(big, goal / 5)2)还需要多少块小的:goal - 5 * min(big, goal / 5)def make_bricks(small, big, goal): if goal / 5 <= big: return goal % 5 <= sm...

2020-02-01 04:30:41 357

原创 【笔试题解】顺时针打印矩阵

题目链接:顺时针打印矩阵(笔试版)备注:《剑指offer》原题,但是在线笔试版本由于输入格式&时间限制,有许多细节需要调整。为了避免超时的tips:(1)不能用Scanner而改用BufferedReader——这里要记住BufferedReader的使用模板&注意事项:-----1.0 需要import的有三个类,也可以直接写:import java.io.*;...

2019-08-19 17:00:07 143

原创 【文献阅读笔记】综述2005 《A Comprehensive Survey of Fitness Approximation in Evolutionary Computation》

关于surrogate-assisted的2005年综述。个人笔记,难免错误,欢迎指正。

2019-07-18 11:45:22 505

原创 Java 字符大小写转换

方法一:char c = 'a';c ^= 0x20; // 'A'char cc = 'B'cc ^= 0x20; // 'b'方法二:char c = 'a';c -= 32; // 'A'char cc = 'B';c += 32; // 'b'方法三:char c = 'a';c = Character.toUppe...

2019-06-26 22:18:57 2160

原创 Java 判断一个点是否在给定矩形内

给出矩形的ABCD四个顶点坐标,待判断点k的坐标(x,y)原理:连接点a与四个顶点,形成四个三角形。如果四个小三角形面积之和等于矩形面积,即说明该点在矩形内部。三角形面积计算公式:代码:public class Solution2 { public static boolean isInner(int[][] loc, int x, int y) { in...

2019-06-19 09:54:42 5138 1

原创 已知顶点/边长,求三角形面积

一 已知顶点坐标,求三角形面积设顶点坐标为则三角形面积为二 已知边长,求三角形面积设三边长分别为 a, b, c。易得半周长则三角形面积为...

2019-06-19 09:21:39 1246

原创 LintCode 打劫房屋 I II III

打劫房屋 ILintCode 打劫房屋思路:采用动态规划思想,小偷从第一个房子开始依次向后移动,设截止到第i个房子时的最大获利为f(i)。移动到第 i 个房子时,有两种选择:打劫第i个房屋,则第i-1个房子不能打劫,因此截止目前获利为 money[ i ] + f(i-2);不打劫第i个房子,则第i-1个房子可以打劫,所以截止目前获利为f(i-1)。到底要不要打劫第i个房子取决于二...

2019-06-04 11:38:40 200

原创 环形链表问题总结——快慢指针

环形链表问题是快慢指针的一个典型应用。其实,称其为“有环链表”更为准确。在有环链表中,利用快慢指针可以解决的问题包括:判断链表是否有环、求环的入口、求环的长度、求链表的总长度(总节点数),等。目录一 判断链表是否有环二 有环链表的入口节点三 有环链表中环的长度3.1 方法一:第一次相遇后继续走,直到第二次相遇3.2 方法二:先求出环的入口节点四 有环链表的总长度...

2019-06-03 21:48:39 1503

原创 快慢指针——找出链表倒数第k个节点

来源:剑指Offer参考:https://www.e-learn.cn/content/qita/2102473思路:设置两个指针,slow和fast都从头结点开始,fast先向前走k步,此时二者相差k个节点;从这里开始,两个指针以相同速度向后移动,保持二者始终相差k步。当fast到达链表尾部时,slow则指向倒数第k个节点。代码:/** * Definition for si...

2019-06-02 21:19:42 422

原创 GitHub+Hexo 搭建个人网站の问题解决记录

前言此篇文章仅用来记录本人作为一枚小白在搭建个人博客的过程中遇到的问题及解决方法,不能作为一篇完整的建站教程。文中的搭建步骤99%参考的是教程:https://zhuanlan.zhihu.com/p/26625249(该教程中有些out of date的内容已记录在本文中——2019.5.29)如果你也和我一样想从零开始搭建一个自己的个人Blog,遇到问题时欢迎来这里找找解决方案。...

2019-05-30 10:13:29 167

原创 快慢指针——求有序链表的中位数

快慢指针的应用: 1. 快乐数 LeetCode 202 2. 环形链表 LeetCode 141 3. 有序链表的中位数(未找到原题,故自己编写了测试用例↓) 4. 找出链表倒数第k个节点剑指Offer参考:https://www.e-learn.cn/content/qita/2102473【快慢指针方法:求一个有序链表的中位数】算法实现&a...

2019-05-28 16:44:26 1726

原创 Git diff命令:究竟是谁和谁对比?

Git中,有 工作区、缓存区(Stage)、HEAD分支三种概念。git add命令将工作区的修改存入缓存区;git commit命令将缓存区的全部内容上传到HEAD所指向的分支(默认为master分支)。现假设经过一些修改、缓存、提交操作后,当前项目中的file.txt文件在工作区、缓存区、HEAD仓库中的版本内容都不一样:工作区记为A,其中的file.txt内容为aaa;...

2019-05-27 16:37:44 936

原创 牛客模拟笔试5月场

原题参考:https://blog.csdn.net/sinat_34136785/article/details/80703895题目一:扑克牌import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scann...

2019-05-15 20:56:24 152

原创 Java复制数组的4种方法:Arrays.copyOf(), Arrays.copyOfRange(), System.arraycopy(), object.clone()

参考:C语言中文网博客园cnblogs代码:int[] a = {1,2,3,4,5};int[] b = Arrays.copyOf(a,10); //有返回值int[] c = Arrays.copyOfRange(a,3,8); //有返回值int[] d = new int[10];System.arraycopy(a,0,d,1,3...

2019-05-13 10:44:46 2715

转载 【转载】Java传递参数的两种方式——值传递 & 引用传递

转自CSDN博客 https://blog.csdn.net/maoyeqiu/article/details/49250339

2019-05-08 09:42:02 157

原创 Integer包装类的方法: valueOf, parseInt, intValue对比

一、Integer类的常用方法 valueOf, parseInt, intValue对比Integer类常用方法 方法名 修饰符 输入 输出 用途 概括为 valueOf static (int i) (String str) Integer 生成Integer实例,值为 int i...

2019-03-07 20:00:57 385

原创 Java易错点

Integer a = 5; Integer b = 5;a==b的结果为true还是false?解析:true。当整数值在 [ -128, 127 ] 范围内时,下列代码结果始终为true:Integer a = 5;Integer b = 5;System.out.println(a == b);原因:当执行 Integer x = 5 时,Java采用自动装箱功能,...

2019-03-07 16:58:34 389

原创 Java各种类型的转换

参考:包装类的介绍一 int 与 Integer1.1 int转Integer方法一:通过Integer类的构造函数int a = 123;Integer b = new Integer(a);方法二:Java的自动装箱功能Integer b = 123;参考我的博客:《Integer包装类的方法: valueOf, parseInt, intValue对比》...

2019-03-07 16:16:58 551

原创 二分搜索总结

BinarySearch题目汇总:LintCode - Binary Searchtemp笔记

2019-02-24 11:08:33 146

原创 排序方法总结

一、时间复杂度的三种排序方法1.1 选择排序//选择排序public static void selectSort(int[] arr) { if(arr == null || arr.length < 2) return; for(int i = 0; i < arr.length-1; i++) { int minIndex = i;...

2019-02-23 11:24:15 106

原创 《算法》第四版 1.1.14 编写一个静态方法lg(),接受一个整形参数N,返回不大于log2(N)的最大整数,不使用Math库。

题目:编写一个静态方法lg(),接受一个整形参数N,返回不大于log2(N)的最大整数,不使用Math库。代码1:public static int log2(int N) { int x = 0,pow = 1; while(pow&lt;=N) { pow *= 2; x++; } return x-1;}代码2:(思路和代码1相同,但没有1容易理解)pu...

2019-01-18 23:34:43 246

原创 【CodingBat】 squareUp问题

问题描述:squareUp问题 Given n&gt;=0, create an array length n*n with the following pattern, shown here for n=3 : {0, 0, 1,    0, 2, 1,    3, 2, 1} (spaces added to show the 3 groups). squareUp(3...

2019-01-17 16:06:54 279

原创 【CodingBat】 linearIn问题 ★★★

问题描述:linearIn问题 ★★★Given two arrays of ints sorted in increasing order, outer and inner, return true if all of the numbers in inner appear in outer. The best solution makes only a single "linear" pa...

2019-01-17 11:18:05 289

原创 【CodingBat】 canBalance问题

问题描述:canBalance问题Given a non-empty array, return true if there is a place to split the array so that the sum of the numbers on one side is equal to the sum of the numbers on the other side.canBal...

2019-01-16 11:12:43 268

原创 【CodingBat】 fix34 & fix45 问题

问题描述:fix34问题Return an array that contains exactly the same numbers as the given array, but rearranged so that every 3 is immediately followed by a 4. Do not move the 3's, but every other number may ...

2019-01-15 17:09:33 195

原创 【CodingBat】maxSpan问题

问题描述:maxSpan问题 Consider the leftmost and righmost appearances of some value in an array. We'll say that the "span" is the number of elements between the two inclusive. A single value has a span o...

2019-01-15 15:09:37 618

原创 【CodingBat】evenOdd问题

问题描述:evenOdd问题 Return an array that contains the exact same numbers as the given array, but rearranged so that all the even numbers come before all the odd numbers. Other than that, the numbers c...

2019-01-14 16:28:28 446

原创 【CodingBat】 zeroMax问题

问题描述:zeroMax问题 Return a version of the given array where each zero value in the array is replaced by the largest odd value to the right of the zero in the array. If there is no odd value to the r...

2019-01-14 11:36:42 196

转载 【转】智力题解答汇总

【1】假设有一个,里面有无穷多的水。现有2个空水壶,容积分别为5升和6升。问题是如何只用这2个水壶从池塘里取得3升的水。答:盛满6,倒进5——6中剩1清空5,把6中的1倒入5盛满6,倒进5——6中剩2清空5,把6中的2倒入5盛满6,倒进5——6中剩3。【2】周雯的妈妈是豫林水泥厂的化验员。 一天,周雯来到化验室做作业。做完后想出去玩。 “等等,妈妈还要考你一个题目,”她...

2019-01-10 16:56:09 151

原创 【CodingBat】tenRun问题的两种解法

问题描述:tenRun问题For each multiple of 10 in the given array, change all the values following it to be that multiple of 10, until encountering another multiple of 10. So {2, 10, 3, 4, 20, 5} yields {2, 1...

2019-01-10 15:26:07 190

原创 程序员刷题面试资源汇总

刷题网站: - NowCoder- Interview Cake - LeetCode - Hacker Rank - CodeEval - TopCoder - CodingBat - Geeks for Geeks - Programming Praxis - Career Cup - Glassdoor- hihoCoderIT类面试书籍: - 《剑指off...

2019-01-10 11:32:57 267

原创 【CodingBat】 twoTwo问题的简洁代码

问题描述:twoTwo问题Given an array of ints, return true if every 2 that appears in the array is next to another 2.examples:twoTwo([4, 2, 2, 3]) → truetwoTwo([2, 2, 4]) → truetwoTwo([2, 2, 4, 2]) → fal...

2019-01-10 11:19:49 537

原创 Java中 Integer.toBinaryString(N) 方法的简单实现

目的:将正整数N用二进制表示并转换为一个String类型的值s。(《算法 第四版》习题1.1.9)代码1:String s = "";for(int n = N; n &gt; 0; n = n / 2) { s = (n % 2) + s;}代码2:(思路一样,繁琐一点)String s = "";int quotient = N;while(quotient...

2019-01-09 22:17:28 1509

原创 Java初始化数组(Array)的三种方法

目的:初始化一个整型数组方法1:☆☆☆int[] a = new int[5];for(int i=0;i&lt;a.length;i++) { a[i] = i;}方法2:★☆☆int[] a = new int[] { 0, 1, 2, 3, 4, 5 };方法3:★★★int[] a = { 0, 1, 2, 3, 4, 5 }; ...

2019-01-08 14:36:03 7421

原创 Matlab 如何删除向量中某几个位置的元素

目的:MATLAB 将向量a中 “向量b对应位置为0的元素” 删除a = [ 1 2 3 4 5 6 ]b = [ 1 0 0 1 1 0 ]命令:a(b==0) = []结果:a = [ 1 4 5 ]

2019-01-08 09:43:26 22712 2

空空如也

空空如也

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

TA关注的人

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