上一页 1 2 3 4 5 6 7 ··· 23 下一页
摘要: 1332. 删除回文子序列 Solution 思路: 回文子序列 所以最多两次,如果一开始就是回文串的话 就是一次。 class Solution { public int removePalindromeSub(String s) { int i =0, j = s.length() - 1; w 阅读全文
posted @ 2022-01-22 11:19 Frontierone 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 2029. 石子游戏 IX Solution 自己思路: 一开始也是分类讨论了,不过是从价值是3的倍数的数字的个数和总和是否是3的倍数来讨论的。 正确思路:首先3的倍数的数字就是双方交替的。但是由于取完也会是Bob获胜,所以这里要讨论3的倍数cnt0的个数的奇偶性。同时要对非3的倍数细分,分为余数为 阅读全文
posted @ 2022-01-20 17:37 Frontierone 阅读(44) 评论(0) 推荐(0) 编辑
摘要: 219. 存在重复元素 II Solution 思路1: 重复元素 然后就用HashMap不断更新最新出现的位置 与k值判断即可。 class Solution { public boolean containsNearbyDuplicate(int[] nums, int k) { Map<Int 阅读全文
posted @ 2022-01-19 16:56 Frontierone 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 539. 最小时间差 Solution 思路: 将所有时间字符串排序后 最小时间只可能是 前后相邻时间 和 首位时间。1440可以剪枝处理,因为24*60。 class Solution { public int findMinDifference(List<String> timePoints) 阅读全文
posted @ 2022-01-19 16:34 Frontierone 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 传送门 Solution 首先找规律可以看出来每个位数$digit$的数字位数之和为$sum_{digit}=digit*10^{digit-1}*9$,所以可以处理出第$n$位所在的数字$value$,根据数字位数之和与$n$的关系,可以得出$value$的位数$digit$,所以可以计算出$di 阅读全文
posted @ 2021-12-01 19:15 Frontierone 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 传送门 Solution 思路1: 滑动窗口。维护窗口内字符的数量,判断与$p$字符串数量是否相等。复杂度$O((sLen-pLen)*26)$ class Solution { public List<Integer> findAnagrams(String s, String p) { int 阅读全文
posted @ 2021-11-29 23:35 Frontierone 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 传送门 Solution 思路1: 暴力 class Solution { public int[] nextGreaterElement(int[] nums1, int[] nums2) { int[] ans = new int[nums1.length]; int cur = 0; for 阅读全文
posted @ 2021-10-26 23:19 Frontierone 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 传送门 Solution 思路1: 暴力搜索 class Solution { public boolean searchMatrix(int[][] matrix, int target) { for (int[] row: matrix) { for (int x : row) { if (x 阅读全文
posted @ 2021-10-26 23:02 Frontierone 阅读(27) 评论(0) 推荐(0) 编辑
摘要: java反射之ObjectAnalyzer 1 在运行时使用反射分析对象 查看对象域的关键方法是Field类中的get方法,如果f是一个Field类型的对象,obj是某个包含f域的类的对象,f.get(obj)将放回一个对象,其值为obj域的当前值。 Employee harry = new Emp 阅读全文
posted @ 2021-10-16 14:29 Frontierone 阅读(96) 评论(0) 推荐(0) 编辑
摘要: Solutions A. Filling Diamonds 通过猜测就欧克了。 发现如果竖直放置就只有一种摆放方法了。 B. Sorted Adjacent Differences 排序后,比较显然的就相距最远的放右边,然后就这样放就可以了。 C. Powered Addition 这个题稍加分析, 阅读全文
posted @ 2020-04-30 22:03 Frontierone 阅读(182) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 23 下一页