标签: 算法
-
PAT A1107
并查集的应用,但是一上来有点蒙蔽,因为这次多了一个媒介,通过活动来判断人员是否在一个集合;有一个示例思路:构建…
-
PAT A1053
也不难,使用DFS就能很好的解决问题;对于DFS的途中节点记录有两种方法,这个需要注意一下:1.使用vecto…
-
46. Permutations
Given a collection of distinct integers, return all pos…
-
39. Combination Sum
Given a set of candidate numbers (candidates) (without …
-
40. Combination Sum II
Given a collection of candidate numbers (candidates) an…
-
PAT A1004
还是数层数和数节点的问题,个人觉得用BFS比较好;当然用DFS也能做,具体的思路就是建立层数数组,深度遍历到x…
-
48. Rotate Image
You are given an n x n 2D matrix representing an image.…
-
33. Search in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated a…
-
49. Group Anagrams
Given an array of strings, group anagrams together.Exam…
-
34. Find First and Last Position of Element in Sorted Array
Given an array of integers nums sorted in ascending ord…