0

when I run the code it gives errror- Line 40: Char 19: fatal error: address of overloaded function 'count' does not match required type 'int' return count; ^~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_algo.h:4074:5: note: candidate template ignored: could not match 'typename iterator_traits<_InputIterator>::diffe

class Solution {
public:


    int numHelper(int start, int count, string cur, string s, string t){



        if(cur == t){
            count++;
            return count;
        }

        if(cur.length()==t.length() && cur == t){
            return count;
        }



        //recursive step
        int i;
        for(i=start; i<s.length(); i++){


             numHelper(i+1, count, cur + s[i] , s, t);
             numHelper(i+1, count, cur  , s, t);
        }


        return 0;
    }




    int numDistinct(string s, string t) {

       numHelper(0, 0, "",  s, t);

           return count;





    }
};
  • you have a `using namespace std;` somewhere and there is [`std::count`](https://en.cppreference.com/w/cpp/algorithm/count). Time to get rid of this bad habit: [Why is “using namespace std;” considered bad practice?](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) – 463035818_is_not_an_ai Jun 06 '20 at 13:42
  • btw there are two things coming together here: In `numDistinct` you do not declare any `count` but yet you return it and the only `count` that the compiler finds is `std::count` – 463035818_is_not_an_ai Jun 06 '20 at 13:44
  • @user:4117728, I am not using that , leetcode is using that , https://leetcode.com/problems/distinct-subsequences/ – KARAN GUPTA Jun 06 '20 at 13:45
  • still this is the major problem here. Without `using namespace std;` the error message would be clear about the error, with it the error message is confusing. – 463035818_is_not_an_ai Jun 06 '20 at 13:47
  • @KARANGUPTA -- unfortunately, programmers tend to personalize code. "First I do this...", or "you do that". What that means (and the way it should be expressed) is "The code does this..." or "the code does that...". So take "you have a `using namespace std;` somewhere" as a neutral comment: "the code has a `using namespace std;` somewhere". If leetcode is inserting that, you (yes, you ) have to figure out how to get rid of it. – Pete Becker Jun 06 '20 at 14:49

0 Answers0