Line 15 error: cannot find symbol: method permuteUnique(int[]) ? Test code error?

  • 0

    Test code Error?

    I tried server solutions, first time I use add hash set based on my AC permutations solution, I got this Compile Error. Then I submit the following no-hash-based-code which is tested on my own laptop. I got the same Compile error. Even also in line 15. Here is my no-hash-based-code:

    import java.util.*;
    public class Solution {
        public List<List<Integer>> permute(int[] nums) {
        	List<List<Integer>> list=new ArrayList<List<Integer>>();
        		List<Integer> tmp=new ArrayList<Integer>();
        		return list;
        	for(int i=0;i<nums.length;i++){
        		int head=nums[i];
        		int[] pool=new int[nums.length-1];
        		int p=0;
        		for(int j=0;j<nums.length;j++)
        			if(i!=j) pool[p++]=nums[j];		
        		List<List<Integer>> tails=permute(pool);
        		int size=tails.size();   		
        		for(int j=0;j<size;j++){
        			List<Integer> sub=new ArrayList<Integer>();
        	return list;
        // if first > second
        public boolean smallerThan(List<Integer> first, List<Integer> second){
        	int f=0,s=0;
        	int len=first.size();
        	for(int i=0;i<len;i++){
        	//System.out.println("f:"+f+" s:"+s);
        	return f<s;

    Then I copy an AC solution from Discuss and I got TLE. Why??

  • 0

    The line number probably refers to judge code, so it's misleading, but... do listen to the rest of the error message. You're missing the method permuteUnique. Yours is called permute.

    Without knowing which AC solution you copied, I can only guess that they added larger test cases after that one was accepted.

  • 0

    Thank you.~.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.