![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
刷题
小王orz
这个作者很懒,什么都没留下…
展开
-
LeetCode 两数之和
明天补上哈希表使用完成度暴力法写了一半自己的代码class Solution { public int[] twoSum(int[] nums, int target) { for(int i = 0; i < nums.length; i++){ for(int j = i+1; j < nums.length; j++)...转载 2019-03-01 00:12:39 · 63 阅读 · 0 评论 -
ECNU || 热河路
思路【数据范围】 对于100%的数据有N≤1500000,Ai≤10^9我们观察序列,发现这个序列可以分为很多组,每一组为1和很多0 0的个数取决于他前面的1是第几个1一种数论方法:只要求出距离k最近的1所在位置即可不难发现 每一个出现1位置都符合n*(n+1)/2+1,于是进行以下推导:设k=n*(n+1)/2(n为最近的1所在位置,k为询问的位数则有2k=n(n+1)可见n=...原创 2019-03-31 22:48:53 · 251 阅读 · 0 评论 -
ECNU ||庙会
代码import java.util.Scanner;import java.util.LinkedList;public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int m = sc.nextInt(); ...原创 2019-04-01 17:27:45 · 138 阅读 · 0 评论 -
ECNU || 定西
思路题目解读很重要,简要说就是有一个楼梯有n个台阶,其中坏了k个台阶不能落脚走,楼梯底部平台编号为0,依次往上自增编号1,2,3…n,n为楼梯顶部的平台。一个人从楼梯底部要走到楼梯顶部去,他一步只能走1个或者2个或者3个台阶,问他有几种方法恰巧能够走到楼梯顶部,不限制步数。把台阶抽象成数组a,a[0]即为楼梯底部的平台处,a[n] 即为所要到达的楼梯顶部。万物皆可遍历!遍历就要进行比对判断,...原创 2019-04-01 19:19:49 · 169 阅读 · 0 评论 -
ECNU || 梵高先生
思路杨辉三角形代码import java.util.Scanner;public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] a = new int[n+1][n+1]; a[1...原创 2019-04-01 19:44:07 · 465 阅读 · 0 评论 -
ECNU ||西班牙馅饼
代码import java.util.Scanner;public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int[][] arr = new int...原创 2019-04-01 19:48:55 · 351 阅读 · 0 评论 -
ECNU || 宇恒棋
思路题目中虽然提到了平局,但是仔细想一下你就会发现根本不存在平局的局面,那么我们来整理一下写题的思路,首先不管两个棋在什么位置他们之间的距离都等于abs((x1 - x2) + (y1 - y2)),如果相距是单数你便输,反之你赢代码import java.util.Scanner;public class Main{ public static void main (String...原创 2019-04-01 20:14:50 · 280 阅读 · 0 评论 -
ECNU || 回文串
java超时代码import java.util.Scanner;public class Main{ public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int...原创 2019-04-01 20:39:40 · 143 阅读 · 0 评论 -
ECNU || 转机折扣
正确代码import java.util.Scanner; //理解字典序public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String str1=sc.next(); String str2=sc.next(); if(str1...原创 2019-03-29 10:09:24 · 127 阅读 · 0 评论 -
LeetCode || 1比特与2比特字符
正确代码class Solution { public boolean isOneBitCharacter(int[] bits) { int i = 0; while(i < bits.length){ if(bits[i] ==0){ i++; }else{ ...原创 2019-03-29 10:21:57 · 90 阅读 · 0 评论 -
Model初学
1.Model addAttribute (String attributeName, Object attributeValue),向模型添加一个变量,attributeName指明了变量的名称,可以再随后的视图里引用,attributeValue代表了变量。2.Mode...原创 2019-05-09 23:54:10 · 1194 阅读 · 0 评论 -
LeetCode撕代码记录
LeetCode随笔,持续更新812. 最大三角形面积给定包含多个点的集合,从其中取三个点组成三角形,返回能组成的最大三角形的面积。个人思路:使用i,j,k三层循环强行遍历所有三个点的情况,并分别使用公式S=1/2[(x1y2-x2y1)+(x2y3-x3y2)+(x3...原创 2019-05-09 23:56:31 · 205 阅读 · 0 评论 -
Spring Boot上传文件初学
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>file测试</title></head>&...原创 2019-05-09 23:58:10 · 119 阅读 · 0 评论 -
ECNU || 和你在一起
思路看到题目首先想到如何使两个数连接在一起最大,例如12和456,连接在一起有两种情况分别为12456和45612,显然后者比前者大。如果是多个正整数连在一起呢,我们需要对元素进行比较,很显然这是一个排序的过程,而且需要相邻的元素两两比较,选择冒泡排序。即:如果是三个数字456,12,342,78,1.我们需要比较12和456,发现45612比12456大,此时交换两个数字 12,456,...原创 2019-03-31 20:59:30 · 141 阅读 · 0 评论 -
LeetCode ||比较含退格的字符串
正确代码根据这一题,掌握数据结构中栈的使用题目分析:题目的意思是,在两个字符串中,对于每一个字符串,如果存在’#‘符号,并且它前面有字符,则删除它前面的字符,’#‘号也删除;如果’#‘前面没有字符,则只删除’#'号;之后再比较两个字符串是不是相等(即剩余的元素相同)。很明显,此题可以使用栈的知识解决:扫描每一个字符串,当读到的字符串中的字符不是’#‘的时候,字符入栈;当读到’#'的时候,如...原创 2019-03-27 13:31:03 · 211 阅读 · 0 评论 -
LeetCode 罗马数字转整数
完成度一点也不会写自己的代码错误照着答案写代码还是错了很多1、s.length(),有括号2、new HashMap< , >(),有括号3、字符用单引号,‘I’题解逆序遍历给定的字符串的每一个字符,根据题中的字符表将字符映射为数字,如果小的数在大的数前面就需要拿大的数减去小的数,否则相加。如:IV,I = 1, V = 5,1 < 5,于是IV = 5 ...原创 2019-03-05 00:09:08 · 153 阅读 · 0 评论 -
HashMap学习
HashMaphttps://www.cnblogs.com/skywang12345/p/3310835.html转载 2019-03-03 20:09:57 · 73 阅读 · 0 评论 -
LeetCode|| 搜索插入位置
完成度没完成自己的代码 int loc; if(nums.length() mod 2 == 0){ loc = num.length()/2; }else{ loc = num.length()/2; }错误考虑奇数偶数,没想清楚题解class Solution { /**...原创 2019-03-09 00:22:59 · 90 阅读 · 0 评论 -
LeetCode 整数反转
完成度写了一半自己的代码忘记保存了错误不知道int型会溢出题解class Solution { public int reverse(int x) { int rev = 0; while(x != 0){ int pop = x % 10; x /= 10; if(rev...原创 2019-03-03 22:12:07 · 161 阅读 · 0 评论 -
LeetCode回文数
完成度写完了,不知道为啥不对,反正就是不对自己的代码class Solution { public boolean isPalindrome(int x) { int i = 0; ArrayList list = new ArrayList(); while(x != 0){ list.add(x % 10);...原创 2019-03-03 23:06:50 · 64 阅读 · 0 评论 -
Leetcode ||二叉树的最大深度
自己的代码/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { ...原创 2019-03-19 23:35:45 · 61 阅读 · 0 评论 -
Leetcode || 将有序数组转换为二叉搜索树
自己的代码/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { ...原创 2019-03-20 10:58:17 · 77 阅读 · 0 评论 -
LeetCode|| 相同的树
深度优先搜索class Solution { public boolean isSameTree(TreeNode p, TreeNode q) { if(p!=null&q!=null){ if(p.val==q.val){ return isSameTree(p.left,q.left)&&...原创 2019-03-17 20:53:22 · 68 阅读 · 0 评论 -
LeetCode||对称二叉树
自己的代码class Solution { public boolean isSymmetric(TreeNode root) { if(root!=null){ if(root.left!=null&amp;&amp;root.right!=null){ if(root.left.val==root.right.v...原创 2019-03-17 21:32:32 · 153 阅读 · 0 评论 -
LeetCode || 二叉树的最小深度
自己写的/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { ...原创 2019-03-25 17:09:42 · 76 阅读 · 0 评论 -
LeetCode || 平衡二叉树
平衡二叉树/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { ...原创 2019-03-25 17:12:13 · 108 阅读 · 0 评论 -
LeetCode || 有效的字母异位词
正确代码class Solution { public boolean isAnagram(String s, String t) { //s.length = t.length if(s.length() != t.length()) return false; char[] S = s.toCharArray(); ...原创 2019-03-27 00:13:23 · 79 阅读 · 0 评论 -
LeetCode || 两个数组的交集
正确代码class Solution { public int[] intersection(int[] nums1, int[] nums2) { HashSet<Integer> nums = new HashSet<Integer>(); HashSet<Integer> result = new HashSet&...原创 2019-03-27 00:38:39 · 130 阅读 · 0 评论 -
创建一个简单的Spring Boot项目
1.打开Idea,File->New->Project,填写组织名称和项目名称。2.在pom.xml中添加代码,声明为Spring Boot项目。 <parent> <groupId>org.springframew...原创 2019-05-09 23:59:16 · 167 阅读 · 0 评论