Sort by

recency

|

1901 Discussions

|

  • + 0 comments

    c++

    int camelcase(string s) {
        int SIZE = s.size();
        int letter_index = 90;
        int result =1;
        for (int i=0;i<SIZE;i++) {
            if (s[i] <= letter_index) {
                result++;
            }
        }return result;
    }
    
  • + 0 comments

    function camelcase(s: string): number { // Write your code here let count = 1; for(let i = 0; i < s.length; i++){ if(s[i].match(/[A-Z]/)){ count++; } } return count;

    }

  • + 0 comments

    my solution in C# public static int camelcase(string s) {

        if(s.Length ==0){
            return 0;
        }
        int count =1;
        count+= s.Count(Char.IsUpper);
        return count;
    }
    
  • + 0 comments

    in C#

    public static int camelcase(string s)
        {
           List<string> totalwords = new List<string>();
           string _singleword ="";
            for(int i=0; i < s.Length; i++){
                if(!char.IsUpper(s[i])){
                    _singleword += s[i];
                }
                else
                {
                    totalwords.Add(_singleword);
                    _singleword = "";
                    _singleword += s[i];
                }
             }
             return totalwords.Count+1;
        }
    
  • + 0 comments

    Here is my easy solution in c++, you can have the explanation here : https://youtu.be/1PDDxGbmSj8

    #include <bits/stdc++.h>
    
    using namespace std;
    
    
    int main()
    {
        string s;
        cin >> s;
        int r = 1;
        for(int i = 0; i < s.size(); i++) {
            if(s[i] < 'a') r++;
        }
        cout << r;
        return 0;
    }