随笔分类 - 编码
摘要:题目 String类型 解答 class Solution { public boolean checkTwoChessboards(String s, String t) { int a = (s.charAt(0) + s.charAt(1)) % 2; int b = (t.charAt(0)
阅读全文
摘要:N皇后 dfs模板 点击查看代码 class Solution { private int ans; public int totalNQueens(int n) { boolean[] col = new boolean[n]; boolean[] diag1 = new boolean[n*2
阅读全文
摘要:循环数组问题,指针问题 代码 比较好实现的,只需要对右端点维护,如果达到了>=k便可以被计数,循环数组可以两边循环做到 点击查看代码 class Solution { public int numberOfAlternatingGroups(int[] colors, int k) { int n
阅读全文
摘要:网络延迟时间 迪杰斯特拉的朴素算法流程: 邻接矩阵的方法 点击查看代码 class Solution { public int networkDelayTime(int[][] times, int n, int k) { //初始化一些必要参数 int INF = Integer.MAX_VALU
阅读全文
摘要:十进制转化任意进制 #include <iostream> #include<cstring> #include <algorithm>//reverse()函数使用所需头文件 using namespace std; string convertToBase8(int num) { string
阅读全文

浙公网安备 33010602011771号