Recursive solution- getting RunTime error


  • 0
    R
    class Solution {
        public List<String> fizzBuzz(int n) {
    	        List<String> result = new ArrayList<String>();
            if(n>0)
    	        return fizzBuzzRecursive(n,result);
            else
                return result;
        }
        public  List<String> fizzBuzzRecursive( int end, List<String> result) {
    
    	       
    	    	  if(end==0)
    	    		  return result;
    	    	  if(end%15==0)   result.add("FizzBuzz");
    	    	  else if(end%3==0) result.add("Fizz");
    	    	  else if(end%5==0) result.add("Buzz");
    	    	  else result.add(String.valueOf(end));
    	    		  
    	       
    	        return fizzBuzzRecursive(end-1,result);
    	        
    	    }
       
    }
    

    I m getting RunTime error. Any suggestions??


Log in to reply
 

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