标签:remove tin tps blog ons 逗号 size bsp visit
示例代码:
1 class Solution { 2 /** 3 * @param nums: A list of integers. 4 * @return: A list of unique permutations. 5 */ 6 public List<List<Integer>> permuteUnique(int[] nums) { 7 // Write your code here 8 ArrayList<List<Integer>> rst = new ArrayList<List<Integer>>(); 9 if (nums == null) { 10 return rst; 11 } 12 if (nums.length == 0){ 13 rst.add(new ArrayList<Integer>()); 14 return rst; 15 } 16 Arrays.sort(nums); 17 ArrayList<Integer> list = new ArrayList<Integer>(); 18 int[] visited = new int[nums.length]; 19 for (int i = 0; i < visited.length; i++) { 20 visited[i] = 0; 21 } 22 helper(rst, list, visited, nums); 23 return rst; 24 } 25 public void helper(ArrayList<List<Integer>> rst, List<Integer> list, int[] visited, int[] nums){ 26 if (list.size() == nums.length) { 27 rst.add(new ArrayList<Integer>(list)); 28 return; 29 } 30 for (int i = 0; i < nums.length; i++) { 31 if (visited[i] == 1 || (i != 0 && nums[i] == nums[i - 1] && visited[i - 1] == 0)){ 32 continue; 33 } 34 visited[i] = 1; 35 list.add(nums[i]); 36 helper(rst, list, visited, nums); 37 list.remove(list.size() - 1); 38 visited[i] = 0; 39 } 40 } 41 }
1.for后有空格;
2.if后有空格;
3.运算符前后有空格 (+-*/, ==, !=, );
4.逗号分号后有空格;
5.if for 的大括号不可省略(- -);
to do perfect……
Google Java Style:https://my.oschina.net/candiesyangyang/blog/225058
标签:remove tin tps blog ons 逗号 size bsp visit
原文地址:http://www.cnblogs.com/buwenyuwu/p/6150333.html