小步惊惊
小步惊惊
全部文章
分类
题解(148)
归档
标签
去牛客网
登录
/
注册
小步惊惊的博客
全部文章
(共33篇)
题解 | #找到字符串中的异位词#
import java.util.*; public class Solution { //先对p字符串进行排序,生成新的字符串,然后判断s的子字符串是否包含有新的p字符串 public ArrayList<Integer> findWord (String s, String p) {...
Java
字符串
数组
2022-06-09
0
430
题解 | #字符串解码#
//采用递归和字符串替换的解法 public class Solution { public String decodeString (String s) { int length = s.length(); //对特殊情况进行处理,只要包含有[字符就要递归下去 if(lengt...
Java
字符串
递归
栈
2022-06-04
0
446
题解 | #质数的计数#
import java.util.*; public class Solution { public int num; public int primesCount (int n) { // write code here //对特殊情况进行处理 if(n<2){ ...
Java
数学
2022-06-03
0
485
题解 | #字母异位词分组#
import java.util.*; public class Solution { public String[][] groupAnagrams (String[] strs) { // write code here //临时字符串数组 String[] temp =...
Java
数组
数学
2022-06-03
0
445
题解 | #合法的括号字符串#
import java.util.*; public class Solution { public boolean isValidString (String s) { // write code here //取代掉() s= s.replaceAll("\\(\\)",...
Java
贪心
字符串
数组
2022-06-03
0
385
题解 | #二叉树展开为单链表#
import java.util.ArrayList; public class Solution { public int number; public void expandTree (TreeNode root) { // write code here if(root==nu...
Java
深度优先搜索
二叉树
链表
2022-06-02
0
512
题解 | #字符流中第一个不重复的字符#
//采用两个集合来解决这个问题,然后借助包含,添加,移除这三个函数 public class Solution { public ArrayList<Character> store = new ArrayList<>(); public ArrayList<Chara...
Java
字符串
有序集合
2022-05-21
0
301
题解 | #最长不含重复字符的子字符串#
//和NC41 最长无重复子数组是一样的解题思路 public class Solution { public int lengthOfLongestSubstring (String s) { // write code here char[] charArray = s.toCh...
Java
字符串
贪心
2022-05-21
0
322
题解 | #删除升序数组的重复元素(二)#
//解题思路就是通过一个for循环来标记重复数字出现的次数,在for循环的过程中更新变量的值 public class Solution { public int removenums (ArrayList<Integer> nums) { // write code here ...
Java
有序集合
计数
2022-05-21
0
418
题解 | #每日温度#
//解题思路就是利用for循环,然后针对特殊情况进行处理 public class Solution { public int[] temperatures (int[] dailyTemperatures) { // write code here if(dailyTemperat...
Java
数组
数学
栈
2022-05-21
0
448
首页
上一页
1
2
3
4
下一页
末页