- 博客(3)
- 收藏
- 关注
原创 java解决矩阵的连通性问题
/* *path是记录矩阵中有块的位置的一个链表,用什么存储不影响,改形参就行 *需要判断的是path中记录有块的位置在二维矩阵中是否是整个连通的 *第一个for循环所做的事情是将path中的块位置映射在2维矩阵中,这时我的矩阵为3行4列矩阵 */ private static boolean check(LinkedList<Integer> path, int[][] nums) { for (int i = 0; i < path.size(); i++) { .
2022-04-02 23:13:04
663
原创 java解决组合与排列问题
注意:组合中的数字是无序的,而排列中的数字是有序的 组合问题 //组合问题 从n中选取k个数的全部组合 class Solution { List<List<Integer>> result = new ArrayList<>(); LinkedList<Integer> path = new LinkedList<>(); public List<List<Integer>> combine(
2022-04-02 22:58:52
1025
1
原创 数与矩阵的快速幂以及矩阵乘法的java实现
//数的快速求幂 public static long fun(long base, int index) { long ans = 1; while (index > 0) { if ((index & 1) == 1) { ans = base * ans; } base = base * base; index >>= 1; } return ans;...
2022-04-02 16:06:06
363
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅