using System;

namespace JanSeven
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine(LengthOfLongestSubstring("dvdf"));
        }

        public static int LengthOfLongestSubstring(string s)
        {
            int LengthOfs = 0;
            bool SubString = false;
            bool SubSequance = false;
            char[] OriginalStrings = s.ToCharArray();
            string SetItStrings = "";

            if (OriginalStrings.Length != 0)
            {
                foreach (char item in OriginalStrings)
                {
                    if (!SetItStrings.Contains(item))
                    {
                        SetItStrings += item;
                        LengthOfs++;
                    }
                }
            }

            for (int i = 0; i <= s.Length - SetItStrings.Length; i++)
            {
                int j;
                for (j = 0; j < SetItStrings.Length; j++)
                    if (s[i + j] != SetItStrings[j])
                        break;
                if (j == SetItStrings.Length)
                {
                    SubString = true;
                }
            }

            if (isSubSequence(SetItStrings, s, SetItStrings.Length, s.Length))
            {
                SubSequance = true;
            }

            if (SubString || !SubSequance)
            {
                return LengthOfs;
            }
            else
            {
                return LengthOfs-1;
            }
        }


        //public static int LengthOfLongestSubstring(string s)
        //{
        //    int LengthOfs = 0;
        //    char[] OriginalStrings = s.ToCharArray();
        //    string SetItStrings = "";

        //    if (OriginalStrings.Length != 0)
        //    {
        //        foreach (char item in OriginalStrings)
        //        {
        //            if (!SetItStrings.Contains(item))
        //            {
        //                SetItStrings += item;
        //                LengthOfs++;
        //            }
        //        }
        //    }
        //    if (isSubSequence(SetItStrings, s, SetItStrings.Length ,s.Length ))
        //    {
        //        return LengthOfs - 1;
        //    }
        //    else
        //    {
        //        return LengthOfs;
        //    }
        //}

        //Returns true if str1[] is a subsequence of str2[] m is length of str1 and n is length of str2
        public static bool isSubSequence(string str1, string str2, int m, int n)
        {

            // Base Cases 
            if (m == 0)
                return true;
            if (n == 0)
                return false;

            // If last characters of two strings 
            // are matching 
            if (str1[m - 1] == str2[n - 1])
                return isSubSequence(str1, str2, m - 1, n - 1);

            // If last characters are not matching 
            return isSubSequence(str1, str2, m, n - 1);
        }
    }
}

the task for Jan 7th, 2021 keeps telling me to there is an error
could you please any one explain to me the error

Comments (0)