自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 寒假-每日一题

class Solution { public List<Integer> majorityElement(int[] nums) { List<Integer> list = new ArrayList<>(); Arrays.sort(nums); int n = nums.length / 3; int count = 0; int flageNum = nums[0...

2022-01-18 23:27:28 155

原创 寒假-每日一题

class Solution { public int dominantIndex(int[] nums) { if (nums == null || nums.length == 1) { return 0; } int max = 0; for (int i = 0; i < nums.length; i++) { if (nums[max] < nums[i]...

2022-01-13 20:56:00 79

原创 寒假-每日一题-day 10

class Solution { public String getHint(String secret, String guess) { int countA = 0; int countB = 0; int[] secretCount = new int[secret.length()]; int[] guessCount = new int[guess.length()]; for (int i = 0...

2022-01-07 23:36:38 195

原创 寒假-每日一题-day 09

class Solution { public String convert(String s, int numRows) { String[] str=new String[numRows]; for(int i=0;i<numRows;i++){ str[i]=""; } int p=0,n=s.length(); while(p<n){ for...

2022-01-07 00:10:49 303

原创 寒假-每日一题-day 08

class Solution { public String addSpaces(String s, int[] spaces) { int[] nums = new int[s.length()]; StringBuffer ans = new StringBuffer(); for(int i = 0; i < spaces.length; i++){ nums[spaces[i]] = 1; ...

2022-01-05 23:06:40 157

原创 寒假-每日一题-day 07

class Solution { public String convertToTitle(int columnNumber) { columnNumber--; int i = columnNumber / ('Z' - 'A' + 1); int j = columnNumber % ('Z' - 'A' + 1); char k = (char) ((int) 'A' + j); if (i == 0) ...

2022-01-04 23:15:25 67

原创 寒假-每日一题-day 06

class Solution { public int[] findErrorNums(int[] nums) { if(nums == null) { return new int[]{}; } int dupli = -1; int miss = -1; for(int i = 0; i < nums.length; i++){ int index =...

2022-01-03 20:12:40 245

原创 寒假-每日一题-day 05

class Solution { public boolean validPalindrome(String s) { int n=s.length(); char[]cs=s.toCharArray(); if(n==1) return true; int l=0; int r=n-1; while(l<r){ if(cs[l]==cs[r]){ l++; .

2021-12-31 22:18:30 164

原创 寒假-每日一题-day 04

class Solution { public int findPoisonedDuration(int[] timeSeries, int duration) { int sum = 0; for(int i=1;i < timeSeries.length ;i++){ if(timeSeries[i] >= timeSeries[i-1] + duration){ sum = sum ...

2021-12-30 17:51:17 124

原创 寒假-每日一题-day 03

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++){ if(nums[i] + nums[j] == target){ return n...

2021-12-29 18:33:59 145

原创 寒假-每日一题-day 02

class Solution { public boolean checkValidString(String s) { int flag1 = 0, flag2 = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == '(') { flag1++; flag2++; }...

2021-12-28 21:20:40 198

原创 寒假-每日一题-day 01

给你一个正整数 n ,生成一个包含 1 到 n的平方 所有元素,且元素按顺时针顺序螺旋排列的 n x n 正方形二维整型数组 matrix ,并将其打印出来.例:输入n = 3那么我们应该生成的二维数组是:提示:1<= n <= 20;package com.atamy.wintervacation.dailyoneproblem;import java.util.Scanner;public class Day01 { public sta...

2021-12-27 20:43:24 236

原创 每日一题 day 08

class Solution { public double myPow(double x, int n) { double ans = 1.0; if(n < 0){ x = 1.0/x; n = -n; }else if(n == 0){ return 1; } for(int i = 0;i < n;i ++){ ...

2021-12-10 20:59:51 3699

原创 每日一题 day 07

package com.atamy.onequestionaday.day7;import java.util.Arrays;public class emm { public static void main(String[] args) { int[] nums = {9,6,4,2,3,5,7,0,1}; Operation operation = new Operation(); System.out.println(ope...

2021-12-09 19:01:28 142

原创 每日一题 day 06

给你一个整数数组nums,请计算数组的中心下标。数组中心下标是数组的一个下标,其左侧所有元素相加的和等于右侧所有元素相加的和。如果中心下标位于数组最左端,那么左侧数之和视为0,因为在下标的左侧不存在元素。这一点对于中心下标位于数组最右端同样适用如果数组有多个中心下标,应该返回最靠近左边的那一个。如果数组不存在中心下标,返回-1。示例 1:输入:nums=[1,7,3,6,5,6]输出:3解释:中心下标是3。左侧数之和sum=...

2021-12-08 19:25:25 90

原创 每日一题 day 05

12.7 每日一题在一个小镇里,按从1到n为n个人进行编号。传言称,这些人中有一个是小镇上的秘密法官。如果小镇的法官真的存在,那么: 1.小镇的法官不相信任何人。 2.每个人(除了小镇法官外)都信任小镇的法官。只有一个人同时满足条件1和条件2。给定一个二维数组trust,该数组中每个元素由键值对形式的信任对trust[i]=[a,b]组成,表示编号为a的人信任编号为b的人。由于trust是一个二维数组,所以每一个trust[i] 是一个一维...

2021-12-07 16:53:00 105

原创 每日一题 day 04

输入一个整数数组和一个整数k,按以下方式修改该数组1.选择某个下标i并将nums[i]替换为-nums[i]2.重复这个过程恰好k次。可以多次选择同一个下标i。以这种方式修改数组后,返回数组可能的最大和。输入:nums=[4,2,3],k=1输出:5解释:选择下标1,nums变为[4,-2,3]。输入:nums=[3,-1,0,2],k=3输出:6输入:nums=[2,-3,-1,5,-4],k=2输出...

2021-12-06 21:16:42 65

原创 每日一题 day 03

12.3每日一题今天又是深化面向对象的一天~题目简介:建立一个Po(点)类,包含数据成员X,Y(坐标点),构造器;以Po为父类,实现一个Circle(圆)类作为子类,增加数据成员R(半径),构造器、求圆面积方法getArea(),求圆周长方法getCircumference();再以Cicle类为父类,实现出一个Cylinder(圆柱体〕子类,增加数据成员H(高),构造器,求圆柱体积方法getVolumn()、求圆柱表面积方法getArea(),请编写程序实现。(圆周率取3.14).

2021-12-03 23:53:54 49

原创 每日一题—day 02

定义一个父类Base中的方法calculate(),该方法用于计算两个数的乘积(X*Y)。定义一个Base类的子类Sub,在Sub中重写calculate()方法,将计算逻辑由乘法改为除法(X/Y)。注意,当分母为0时输出“Error”。输入描述:两个整数输出描述:两个整数的积和商(int类型,不考虑小数情况)示例1输入:62输出:3 12示例2输入:1 0输出: Error 0运行结果:...

2021-12-02 17:18:24 86

空空如也

空空如也

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

TA关注的人

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