Java Solution Failing


  • 0
    D
    public class Solution {
        public int getMaxRepetitions(String s1, int n1, String s2, int n2) {
            int x = s2.length();
            int j = 0;
            int count = 0;
            for (int i = 0 ; i< s1.length(); i++){
                    char ci = s1.charAt(i);
                    char cj = s2.charAt(j);
                    if (ci == cj){
                        j++;
                    }
                    if ( j == x){
                        j = 0;
                        count ++;
                    }
                }
            if (count ==0)
                {return 0;}
            else{
                return (n1 /n2)*count;
            }
            
            }
        
    
    
    
    Teast case Failing :
    
    Input:
    "lovenicoloveliveniconiconiconiniconjcoaaajo"
    201641
    "lovenanjo"
    401
    Output:
    0
    Expected:
    251
    }
    

Log in to reply
 

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