Beispiel #1
0
int main(int argc, char const *argv[]) {
    char s1[] = "abcabcbb";
    char s2[] = "bbbbb";
    char s3[] = "pwwkew";

    assert(lengthOfLongestSubstring(s1) == 3);
    assert(lengthOfLongestSubstring(s2) == 1);
    assert(lengthOfLongestSubstring(s3) == 3);
    return 0;
}
Beispiel #2
0
int main(int argc, char **argv)
{
    char s1[] = "abba";
    char s2[] = "abca";
    char s3[] = "abcb";
    char s4[] = "pwwkew";
    char s5[] = "tmmzuxt";
    char s6[] = "aa";
    //printf("%d\n", lengthOfLongestSubstring(s1));
    //printf("%d\n", lengthOfLongestSubstring(s2));
    //printf("%d\n", lengthOfLongestSubstring(s3));
    printf("%d\n", lengthOfLongestSubstring(s4));
    printf("%d\n", lengthOfLongestSubstring(s5));
    printf("%d\n", lengthOfLongestSubstring(s6));
    return 0;
}
int main(int argc, char* argv[]) {
	char s[] = "abcbef";
	int len = lengthOfLongestSubstring(s);
	printf("%d\n", len);

	return 0;
}
Beispiel #4
0
int main()
{
	char string[STRING_LENGTH];
	gets_s(string, STRING_LENGTH * sizeof(char));
	printf("%d", lengthOfLongestSubstring(string));
	return 0;
}
Beispiel #5
0
int main(){
	char * x = "abc";
	int len = lengthOfLongestSubstring(x);
	printf("%d\n", len);
    getchar();
    return 0;
}
int main(){
    char string[] = "abcdefgdqwertyuio";

    int max = lengthOfLongestSubstring(string);

    printf("The Max length is %d\n",max);
    return 0;
}
	void test() {
		vector<string> v = { "abcabcbb", "bbbbb", "a", "",
			"hchzvfrkmlnozjk",
			"wlrbbmqbhcdarzowkkyhiddqscdxrjmowfrxsjybldbefsarcbynecdyggxxpklorellnmpapqfwkhopkmco" };
		for (string s : v) {
			int result = lengthOfLongestSubstring(s);
			cout << s << " : " << result << endl;
		}
	}
int main(int argc, char const *argv[])
{
    char *s = "pwwkew";
    //char *s = "abcabcbb";
    //char *s = "au";
    printf("parse string:%s \n", s);
    lengthOfLongestSubstring(s);
    return 0;
}
void testLengthOfLongestSubstring(){
    string s= "hchzvfrkmlnozjk";
    int ret = lengthOfLongestSubstring(s);
    printf("It's %d\n",ret);
    static int p;//静态变量与全局变量的初始值维0
    static int *ppint;
    int *p2 = &p;
    printf("Finished");
}
Beispiel #10
0
int main(int argc, const char * argv[]) {
    // insert code here...    
    printf("LeetCode 003 Longest Substring Without Repeating Characters, C ... ...\n");

    //char s[] = "epqcrkeyjzbkvkrganbg";
    char s[] = "abcdbef";
    printf("%s\n", s);

    printf("\n%d\n", lengthOfLongestSubstring(s));


    return 0;
}
Beispiel #11
0
Datei: 3.c Projekt: unasm/utils
int main(int argc, const char *argv[])
{
	//char str[] = "abcab";int expect = 3;
	//char str[] = "aaaaa";int expect = 1;
	//char str[] = "au";int expect = 2;
	//char str[] = "abba";int expect = 2;
	char str[] = "abbaacd";int expect = 3;
	int res = lengthOfLongestSubstring(str);
	if (res == expect) {
		printf("yes\n");
	} else {
		printf("%d\n", res);
	}
	return 0;
}
		int lengthOfLongestSubstring(string s) 
		{
			if (s.size() <= 1)
				return s.size();

			int tmp = lengthOfLongestSubstring(s.substr(1));
			for ( int i=0; i<tmp+1; i++)
			{					
				for (int j=i+1; j<tmp+1; j++)
				{
					if ( s.at(i) == s.at(j) )
						return tmp;
				}
			}
				
			return tmp + 1;
		}
 bool testing(){
     //tesing empty string
     if(lengthOfLongestSubstring("")!=0)
         return false;
     //testing for case sensitivity
     if(lengthOfLongestSubstring("abAB")!=4)
         return false;
     //testing for space considering it invalid
     if(lengthOfLongestSubstring("hello spaces")!=-1)
         return false;
     //testing for all set of characters (numbers and special characters)
     if(lengthOfLongestSubstring("123@asA")!=7)
         return false;
     //testing for no string with unique characters
     if(lengthOfLongestSubstring("abcd")!=4)
         return false;
     //testing for same character
     if(lengthOfLongestSubstring("gggggg")!=1)
         return false;
     //random example
     if(lengthOfLongestSubstring("abcdbca")!=4
        return false;
 }
Beispiel #14
0
int main() {
    printf("%d\n", lengthOfLongestSubstring("abcabcbb"));

    return 0;
}
Beispiel #15
0
int main(int argc, char **argv) {
    char * s = "multimonial";
    if (argc >= 2) s = argv[1];
    printf("%d", lengthOfLongestSubstring(s));
    return 0;
}
Beispiel #16
0
int main(int argc, char** argv)
{
    printf("%d\n", lengthOfLongestSubstring(argv[1]));
    return 0;
}
void main(int argc, char * argv[]) {

  if (argc != 2) {
    printf("Please specify the correct arguments.\n");
    return;
  }

  printf("The length of the longest substring without repeating characters in \"%s\" is %d.\n", argv[1], lengthOfLongestSubstring(argv[1]));

}
Beispiel #18
0
int main(){
	char s[] = "dvdvdvffdf";
	int len = lengthOfLongestSubstring(s);
	printf("Longest length: %d",len);
	return 0;	
}
void testLengthOfLongestSubstring()
{
    char *p="pwwkew";
    printf("%d",lengthOfLongestSubstring(p));
}
int main(void) {
    char a[] = "1233567";
    printf("%d\n", lengthOfLongestSubstring(a));
    return 0;
}
Beispiel #21
0
int main()
{
    int nums = lengthOfLongestSubstring("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ abcd'");
    printf("long :%d\n", nums);
}
Beispiel #22
0
int main(int argc, char *argv[])
{
	printf("%d\n", lengthOfLongestSubstring(argv[1]));
	//printf("%d\n", lengthOfLongestSubstring("nxaxxx"));
	return 0;
}