LeetCode brush title the next day --3Longest Substring Without repeating character 4 AddTwoList

Point of confusion:

  Continuous substring

  Sequence may be discontinuous

Knowledge points:

  HashMap:

problem appear:

  1. error when using header files unordered_map

#error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.#end if

 

  Solution:

  Right on the project, select the build options, the compiler settings inside, there is a list, select c ++ 0x support.

  PS: This error is more strange is that he jump directly to the header file. So you can know that this is not their mistakes, to change the way the project was compiled just fine.  

  Resolution code:

. 1  // Leetcode. 3 # 
2 // Title Description: Given a string seeking the maximum number of sub-strings . 5 . 6 #include <stdio.h> . 7 #include <the iostream> . 8 #include <Vector> . 9 #include <unordered_map> 10 the using namespace STD; . 11 12 is 13 is class Solution { 14 public : 15 int lengthOfLongestSubstring ( String S) 16 { . 17 int RES = 0 , left = - . 1 , = n- s.size (); 18 is unordered_map<int,int> m; 19 for(int i=0;i<n;++i) 20 { 21 //count check whether s[i] exist 22 if(m.count(s[i])&&m[s[i]]>left) 23 { 24 left=m[s[i]]; 25 26 } 27 //update s[i]'s position 28 m[s[i]]=i; 29 res=max(res,i-left); 30 31 } 32 return res; 33 } 34 }; 35 36 37 38 39 40 41 int main() 42 { 43 Solution s;//initializing object s 44 string str1="abttybacds"; 45 int t=0; 46 t=s.lengthOfLongestSubstring(str1); 47 cout<<t<<endl; 48 return 0; 49 }

 https://www.cnblogs.com/grandyang/p/4480780.html

Explain this there is also the rest of the several methods

4.Median of Two Sorted Arrays two ordered arrays median Hard

 

Guess you like

Origin www.cnblogs.com/Marigolci/p/10987999.html