自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

龍淵的博客

懒人一枚,没得描述

  • 博客(51)
  • 资源 (1)
  • 收藏
  • 关注

原创 OJ---Z 字形变换

OJ题

2022-06-27 20:01:26 158 1

原创 OJ---最长公共前缀

OJ题

2022-06-21 19:47:36 172

原创 OJ---独一无二的出现次数

OJ题

2022-06-21 19:10:32 132

原创 OJ---将找到的值乘以 2

OJ---将找到的值乘以 2

2022-06-21 17:42:34 106

原创 GO学习项目---家庭收支记账软件

主菜单功能实现:func (f *FamilyAccount) MainMenu() { for { fmt.Println("-----------家庭收支记账软件-----------") fmt.Println(" 1.收支详细") fmt.Println(" 2.登记收入") fmt.Println(" 3.登记支出") fmt.Println(" 4.退 出") fmt.Print("

2022-05-23 16:53:36 161

原创 OJ---盛最多水的容器

一开始用的双for循环移动左右指针,提交超时。然后发现只需要移动高度较低的那个指针就行class Solution { public int maxArea(int[] height) { if(height.length<=1){ return 0; } if(height.length==2){ if(height[0]!=0 && height[1]!=0){

2022-05-11 19:13:16 72

原创 OJ---数据分类处理

import java.util.*;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String one[] = in.nextLine().split(" "); String two[] = in.nextLine().split(" "); int Ln = Integer.va

2022-04-20 17:56:11 148

原创 OJ---查找组成一个偶数最接近的两个素数

import java.util.*;public class Main { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int arr[] = new int[n]; Arrays.fill(arr,1); ArrayList<Integer> lis

2022-04-20 17:02:43 116

原创 OJ---腐烂的橘子

运用广度优先搜索(BFS)class Solution { public int orangesRotting(int[][] grid) { int count=0;//记录新鲜橘子 int N = grid.length;//记录数组的行 int M = grid[0].length;//记录数组的列 Queue<int[]> queue = new LinkedList<>(); for(

2022-04-20 16:07:18 403

原创 OJ---接雨水问题

import java.util.*;public class Solution { /** * max water * @param arr int整型一维数组 the array * @return long长整型 */ public long maxWater (int[] arr) { // write code here int top = 0; int max = 0; f

2022-04-19 16:09:23 133

原创 OJ---二叉搜索树的后序遍历序列

即如果把中序序列当做栈的压入序列,那么后序序列是该栈的一个弹出序列import java.util.*;public class Solution { public boolean VerifySquenceOfBST(int [] sequence) { int[] arr = sequence.clone(); Arrays.sort(arr); return IsPopOrder(arr,sequence); } publi

2022-04-19 15:20:24 677

原创 OJ---从上往下打印二叉树

通过队列来实现二叉树的广搜public class Solution { public ArrayList<Integer> PrintFromTopToBottom(TreeNode root) { Queue<TreeNode> queue = new LinkedList<TreeNode>(); ArrayList<Integer> arr = new ArrayList<>();

2022-04-19 14:30:02 334

原创 OJ---称砝码

import java.util.*;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int num[] = new int[n]; int weight[] = new int[n]; for (int i = 0; i &l

2022-04-18 17:18:02 114

原创 OJ---最小覆盖子串

import java.util.*;public class Solution { /** * * @param S string字符串 * @param T string字符串 * @return string字符串 */ public String minWindow (String S, String T) { // write code here int l=0,r=0; i

2022-04-18 16:21:17 115

原创 OJ---最长回文子串

import java.util.*;public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param A string字符串 * @return int整型 */ public int getLongestPalindrome (String A) { // write code here if(A

2022-04-18 15:33:11 105

原创 OJ---最长连续递增序列

记录当前连续递增序列的开始下标和结束下标,遍历数组的过程中每次比较相邻元素,根据相邻元素的大小关系决定是否需要更新连续递增序列的开始下标class Solution { public int findLengthOfLCIS(int[] nums) { int max = 0; int start = 0; if(nums.length==1){ return 1; } for(int i=0;

2022-04-18 15:03:43 117

原创 OJ---组合

class Solution { public List<List<Integer>> combine(int n, int k) { List<List<Integer>> res = new ArrayList<>(); if(k==0||n<k){ return res; } Deque<Integer> path = new A

2022-04-18 14:34:23 56

原创 OJ---有重复字符串的排列组合

class Solution { LinkedList<String> list = new LinkedList<>(); public String[] permutation(String S) { dfs(S.toCharArray(),0); return list.toArray(new String[0]); } public void dfs(char[] c,int k){ if(k==

2022-04-17 18:33:05 94

原创 OJ---括号的最大嵌套深度

import java.util.*;class Solution { public int maxDepth(String s) { int count = 0; int num = 0; for(char ch:s.toCharArray()){ if(ch=='('){ count++; }else if(ch=='['){ cou

2022-04-17 17:08:43 107

原创 OJ---有效括号序列

import java.util.*;public class Solution { /** * * @param s string字符串 * @return bool布尔型 */ public boolean isValid (String s) { // write code here if(s==null){ return false; } Stack

2022-04-16 17:14:00 150

原创 OJ---成绩排序

import java.util.*;class student { private int grade; private String name; public static final Comparator<student> up = new up(); public static final Comparator<student> down = new down(); public student(String name, int g

2022-04-16 16:58:13 209

原创 OJ---合并区间

import java.util.*;/** * Definition for an interval. * public class Interval { * int start; * int end; * Interval() { start = 0; end = 0; } * Interval(int s, int e) { start = s; end = e; } * } */public class Solution { public

2022-04-16 16:19:47 106

原创 OJ---查找兄弟单词

兄弟单词判断步骤:1、跳过长度不一和完全相同的单词。2、将2个String变为char[]。3、对char[]进行排序,然后转为2个String。4、对比两个String是否完全相同import java.util.*;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String temp[] = in.ne

2022-04-16 15:54:22 103

原创 OJ---字符串排序

这里有一个细节:nextInt执行后光标停在读取到的int之后,但本行并未结束,还有换行符没有读取。使用nextInt之后使用nextLine手动换行。即在int n = in.nextInt();后面加上一行:in.nextLine();import java.util.*;public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in);

2022-04-15 17:40:23 91

原创 OJ---合并表记录

要求有序所以使用TreeMap而不是Mapimport java.util.*;public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); TreeMap<Integer,Integer> map = new TreeMap<>();

2022-04-15 17:18:45 45

原创 OJ---字符逆序

直接使用StringBuilder的reverse()方法import java.util.*;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); StringBuilder temp = new StringBuilder(str);

2022-04-15 17:00:26 170

原创 OJ---输入整型数组和排序标识,对其元素按照升序或降序进行排序

Arrsys.sort()是从小到大排序,要想降序排列需要用到Comparator。注意如果是int arr[]会发生报错,必须使用Integer arr[]import java.util.*;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); Intege

2022-04-15 16:50:24 79

原创 OJ---整数与IP地址间的转换

重点在于字符串的处理,和String与int与二进制之间的变化import java.util.*;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str[] = in.nextLine().split("\\."); Long n = in.nextLong(); Sy

2022-04-15 16:04:40 74

原创 OJ---密码验证合格程序

难点在于检测重复子串和大小写字母.数字.其它符号,以上四种至少三种通过Pattern建立正则表达式,使用Pattern.matcher().find()查找字符串中部分匹配子串import java.util.*;import java.util.regex.*;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); S

2022-04-14 17:12:43 193

原创 OJ---坐标移动

public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); String temp[] = str.split(";"); int x = 0, y = 0; String res = "[AWSD]\\d{1,2}";//正则表达式 for (String s

2022-04-14 16:03:15 52

原创 OJ---字符个数统计

采用Map存储出现过的字符,用map.containsKey()方法查看是否重复字符public static void main(String[] args){ Scanner in = new Scanner(System.in); String str = in.nextLine(); Map<Character,Integer> map = new HashMap<>(); for(char ch:str.to

2022-04-14 14:31:18 310

原创 OJ---24点运算

采用穷举法import java.util.*;public class Main{ public static void main(String[] args){ String fuhao[] = {"+","-","*","/"}; Scanner in = new Scanner(System.in); String str = in.nextLine(); String s[] = str.split(" ");

2022-04-14 14:13:41 69

原创 OJ---明明的随机数

题目要求:去重,从小到大排列。完美符合TreeSet的性质public static void main(String[] args){ Scanner in = new Scanner(System.in); int N = in.nextInt(); int arr[] = new int[N]; TreeSet ts = new TreeSet(); for(int i=0;i<N;i++){

2022-04-12 17:46:41 90

原创 OJ---两数之和

第一种:暴力解法,双for循环遍历。当数组量太大时会超时public int[] twoSum (int[] numbers, int target) { // write code here int temp; int twoSum[] = new int[2]; for(int i=0;i<numbers.length;i++){ for(int j=i+1;j<numbers.length;j++){

2022-04-12 15:58:26 149

原创 OJ---进制转换

从字符串的最高位开始提取字符,通过Map转成对应数字进行计算,通过Math.pow计算16的n次幂import java.util.*;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str; while (in.hasNext()) { str = in.nex

2022-04-11 16:36:34 296

原创 OJ---删除字符串中出现次数最少的字符

一开始想用arr[128]对应各个字符,数组的值就是出现次数。发现实现char字符与arr[i]对应很麻烦,参考了别人的思路就换成HashMap实现。import java.util.*;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNext()) { String

2022-04-11 15:46:53 207

原创 OJ--重建二叉树

先序数组的首位是根节点,通过根节点将中序数组分为左子树,右子树。再通过递归完成重建。public class Solution { public TreeNode reConstructBinaryTree(int [] pre,int [] vin) { if(pre.length==0||vin.length==0){ return null; } TreeNode root = new TreeNode(pre[0]);

2022-04-08 15:12:14 419

原创 OJ---二维数组中的查找

题目:在一个二维数组array中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。思路:将初始值设为二维数组右上角那个数,即array[0][m]若target大于这个数则往下移一行若target小于这个数则往左移一列public class Solution { public boolean Find(int target, int [][] array) { boolean exist = false;

2022-04-07 14:45:47 158

原创 OJ---大数相加

这次没有用JAVA自带的BigInteger,思路就是将输入的String每一位数字转换成Int相加得到结果temp,temp除以10得到进位c,temp除余10后用StringBuilder.insert方法插入到字符序列中import java.util.Scanner;public class Solution { public String solve (String s, String t) { // write code here String s

2022-03-30 18:01:12 84

原创 OJ---查找学生信息

#include<iostream>#include<string>#include<unordered_map>using namespace std;struct student { string name; string sex; int value;};unordered_map<int, student> hashs;int main() { int N,id; cin >> N; student s;

2022-03-22 15:24:59 115

大学毕业设计代码 基于艾宾浩斯遗忘曲线的APP

使用的AS版本为4.1.2,其他AS版本可能会导致报错无法运行

2022-01-11

空空如也

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

TA关注的人

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