上一页 1 ··· 19 20 21 22 23
摘要: 30. 串联所有单词的子串 题解: 题目可以转换为:把字符串s按word的长度划分为一堆集合后,然后这一堆集合中,找出完全由words集合组成的字符串。 滑动窗口,每次滑动按一个word的长度滑,当窗口内的元素完全等于words的元素时,此时的下标即为答案。 class Solution { pub 阅读全文
posted @ 2022-11-06 00:56 Eiffelzero 阅读(31) 评论(0) 推荐(0)
摘要: 29. 两数相除 题解: a / b = y 等价于 b > a - (b * y) > 0 , 只要求出减了多少次b就好了。 一个一个地减b,效率太低了,最坏情况下, a = 2^31 - 1 , b = 1 ,超时; 应该先预处理出 b * 2^k (最多不超过31个), 然后从大到小被 a减, 阅读全文
posted @ 2022-11-05 13:52 Eiffelzero 阅读(79) 评论(0) 推荐(0)
摘要: 1106. 解析布尔表达式 题解:每个小括号都可以优先递归计算,dfs class Solution { int index; char[] ch; public boolean parseBoolExpr(String expression) { ch = expression.toCharArr 阅读全文
posted @ 2022-11-05 12:04 Eiffelzero 阅读(28) 评论(0) 推荐(0)
摘要: 754. 到达终点数字 class Solution { public int reachNumber(int target) { target = Math.abs(target); int n = 0, sum = 0; while(sum < target || (sum - target) 阅读全文
posted @ 2022-11-04 21:54 Eiffelzero 阅读(20) 评论(0) 推荐(0)
摘要: 1668. 最大重复子字符串 方法一:暴力枚举 class Solution { public int maxRepeating(String sequence, String word) { char[] ch1 = sequence.toCharArray(); int res = 0; Str 阅读全文
posted @ 2022-11-03 23:10 Eiffelzero 阅读(32) 评论(0) 推荐(0)
摘要: 1620. 网络信号最好的坐标 题解:数据范围小,直接暴力枚举所有点,然后计算贡献,取最大值即可 class Solution { public int[] bestCoordinate(int[][] towers, int radius) { int n = towers.length; int 阅读全文
posted @ 2022-11-02 23:44 Eiffelzero 阅读(19) 评论(0) 推荐(0)
摘要: 检查两个字符串数组是否相等 class Solution { public boolean arrayStringsAreEqual(String[] word1, String[] word2) { StringBuilder w1 = new StringBuilder(); for (Stri 阅读全文
posted @ 2022-11-01 09:29 Eiffelzero 阅读(27) 评论(0) 推荐(0)
摘要: 神奇字符串 题解:模拟这个神奇字符串,然后直接统计1的个数即可 class Solution { public int magicalString(int n) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.ap 阅读全文
posted @ 2022-10-31 20:38 Eiffelzero 阅读(18) 评论(0) 推荐(0)
摘要: 784. 字母大小写全排列 字母大小写全排列。 题解: 按题意模拟,DFS遍历string的每个下表字符,并对其按题意操作,遍历完添加到答案。 class Solution { public List<String> letterCasePermutation(String s) { char[] 阅读全文
posted @ 2022-10-30 02:10 Eiffelzero 阅读(25) 评论(0) 推荐(0)
摘要: 参考: https://www.yuque.com/awescnb/user https://github.com/BNDong/Cnblogs-Theme-SimpleMemory 阅读全文
posted @ 2022-10-30 01:25 Eiffelzero 阅读(19) 评论(0) 推荐(0)
上一页 1 ··· 19 20 21 22 23
点击右上角即可分享
微信分享提示