摘要:
#饿汉式 public class Singleton{ public final static INSTANCE = new Singleton(); private Singleton(){ } } /*枚举类型限制对象个数,当我们只写一个就变成了单例模式 */ public enum Sing 阅读全文 »
摘要:
##暴力题解:双重for循环,时间复杂度O(n^2) class Solution { public int max(int a,int b){ if(a>=b) return a; return b; } public int min(int a,int b){ if(a>=b) return b 阅读全文 »
摘要:
题目链接:https://leetcode-cn.com/problems/magic-index-lcci/ 间接跳跃查找(leetcode给的测试好像都是递增的) class Solution { public int findMagicIndex(int[] nums) { for(int i 阅读全文 »
摘要:
深度优先 class Solution { public boolean exist(char[][] board, String word) { char[] words = word.toCharArray(); int m = words.length; boolean[][] visit = 阅读全文 »
摘要:
深度优先搜索:将问题划分为,邻近的四个方向格子所能到达的格子数+1,由于又是从0,0开始的所以只用右、下两个方向的邻近格子就行了。 class Solution { boolean[][] visited; public int movingCount(int m, int n, int k) { 阅读全文 »