- 博客(2)
- 收藏
- 关注
原创 无向图的多重邻接表(作业)
package graph; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import graph.MultilinkedListUndirectedGraph.edges; public class MultilinkedListUndirectedGraph<T> implements IGraph { private static GraphKind grag
2021-04-24 15:31:45 257
原创 森林中,每个兔子都有颜色。其中一些兔子(可能是全部)告诉你还有多少其他的兔子和自己有相同的颜色。我们将这些回答放在 answers 数组里。(题目来自力扣,博客作为个人日志)
由于数组内给的数据可能是比较杂乱的,但是目前还没有学过map,所以进行了数组排序,然后进行了递归操作,代码的逻辑很简单,代码如下: class Solution { public int numRabbits(int[] answers) { if(answers.length == 0){ return 0; } Arrays.sort(answers); return help(answers, 0, 0);
2021-04-04 13:21:16 202
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人