275. H 指数 II
摘要:说明: 如果 h 有多有种可能的值 ,h 指数是其中最大的那个。 package leetcode; public class HindexIISolution { public int hIndex(int[] citations) { if(citations==null ||citations
阅读全文
posted @
2020-09-18 00:19
凌晨三点半的飞机
阅读(147)
推荐(0)
274. H 指数
摘要:package leetcode; import java.util.Arrays; public class HindexSolution { public int hIndex(int[] citations) { Arrays.sort(citations); for(int i =0 ; i
阅读全文
posted @
2020-09-17 00:48
凌晨三点半的飞机
阅读(166)
推荐(0)
只出现一次的数字 III
摘要:package my; import java.util.HashMap; import java.util.Map; public class SingleNumberSolution { public int[] singleNumber(int[] nums) { int[] result =
阅读全文
posted @
2020-09-17 00:06
凌晨三点半的飞机
阅读(178)
推荐(0)
缺失数字
摘要:package my; import java.util.Arrays; public class MissNumberSolution { public int missingNumber(int[] nums) { Arrays.sort(nums); if (nums[nums.length-
阅读全文
posted @
2020-09-15 02:23
凌晨三点半的飞机
阅读(189)
推荐(0)
丑数
摘要:package my; public class IsUglySolution { boolean isUgly(int num){ if(num == 0){ return false; } while(num !=1){ if(num % 2 == 0){ num /= 2 ; continue
阅读全文
posted @
2020-09-15 01:35
凌晨三点半的飞机
阅读(158)
推荐(0)
移动零
摘要:class Solution { public void moveZeroes(int[] nums) { int result=0 ; for(int i =0 ;i < nums.length;i ++){ if(nums[i]!= 0){ nums[result++] = nums[i]; }
阅读全文
posted @
2020-09-15 00:48
凌晨三点半的飞机
阅读(176)
推荐(0)
判断字符串中出现次数最多的字符和出现次数
摘要:package my; import java.util.HashMap; public class FindStringMaxSolution { int findStrMax(String str){ if(str.length() == 0 || str == null){ return -1
阅读全文
posted @
2020-09-14 02:08
凌晨三点半的飞机
阅读(209)
推荐(0)
找出字符串中第一个只出现一次的字符
摘要:找出字符串中第一个只出现一次的字符 package my; import java.util.HashMap; //问题:在一个字符串(0<=字符串长度<=10000,全部由字母组成)中找到第一个只出现一次的字符, //并返回它的位置, 如果没有则返回 -1(需要区分大小写). public cla
阅读全文
posted @
2020-09-14 00:09
凌晨三点半的飞机
阅读(261)
推荐(0)
输入两个字符串,从第一字符串中删除第二个字符串中所有的字符。
摘要:package my; import java.util.HashMap; public class DelStringSolution { //输入两个字符串,从第一字符串中删除第二个字符串中所有的字符。 //例如,输入”They are students.”和”aeiou”,则删除之后的第一个字
阅读全文
posted @
2020-09-13 18:56
凌晨三点半的飞机
阅读(1187)
推荐(0)
整数转罗马数字
摘要:package my; public class RomanNumberSolution { public String intToRoman(int num){ String[] thousands = {"", "M", "MM", "MMM"}; String[] hundreds = {""
阅读全文
posted @
2020-09-11 22:21
凌晨三点半的飞机
阅读(152)
推荐(0)
盛最多水的容器
摘要:package my; public class MaxAreaSolution { public int maxArea(int[] height){ if(height.length <1){ return 0; } int max = 0; int current =0; for(int i=
阅读全文
posted @
2020-09-11 02:53
凌晨三点半的飞机
阅读(178)
推荐(0)
删除重叠的区间的个数
摘要:删除重叠的区间的个数 package my; import java.util.Arrays; public class NoOverlapIntervals2 { int eraseOverlapIntervals(int[][] intervals){ if(intervals.length =
阅读全文
posted @
2020-09-09 02:23
凌晨三点半的飞机
阅读(297)
推荐(0)
无重叠区间435
摘要:无重叠区间: package my; import java.util.Arrays; //435.无重叠区间 public class NoOverlapIntervals { int eraseOverlapIntervals(int[][] intervals){ //在主体函数里,先将区间按
阅读全文
posted @
2020-09-08 00:30
凌晨三点半的飞机
阅读(197)
推荐(0)
合并区间
摘要:package my; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class MergeIntervals { int[][] merge(int[][] intervals)
阅读全文
posted @
2020-09-06 15:08
凌晨三点半的飞机
阅读(200)
推荐(0)