File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
longest-substring-without-repeating-characters Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ # μ°κ΄ λ§ν¬
2
+ - [ λ¬Έμ νμ΄ μ€μΌμ€] ( https://github.com/orgs/DaleStudy/projects/6/views/5 )
3
+ - [ λ΅μ μ½λ μ μΆλ²] ( https://github.com/DaleStudy/leetcode-study/wiki/%EB%8B%B5%EC%95%88-%EC%A0%9C%EC%B6%9C-%EA%B0%80%EC%9D%B4%EB%93%9C )
4
+
5
+ # Problem
6
+ - λ¬Έμ λ§ν¬ : https://leetcode.com/problems/longest-substring-without-repeating-characters/description/
7
+ - λ¬Έμ μ΄λ¦ : Longest Substring Without Repeating Characters
8
+ - λ¬Έμ λ²νΈ :3
9
+ - λμ΄λ : medium
10
+ - μΉ΄ν
κ³ λ¦¬ :
11
+
12
+ # μμ΄λμ΄
13
+ - λ§μ§λ§ μμΉμ λν μ μ₯μ ν΅ν λΉ λ₯Έ νμ
14
+
15
+ # β
μ½λ (Solution)
16
+
17
+ ``` cpp
18
+ class Solution {
19
+ public:
20
+ int lengthOfLongestSubstring(string s) {
21
+ unordered_map<char, int> latestIdx;
22
+ int maxLength = 0;
23
+ int start = 0;
24
+ for(int idx = 0; idx<s.size();idx++){
25
+ char curC = s[ idx] ;
26
+ if(latestIdx.find(curC) != latestIdx.end() && latestIdx[ curC] >= start){
27
+ start = latestIdx[ curC] +1;
28
+ }
29
+ latestIdx[ curC] = idx;
30
+ maxLength = max(maxLength, idx-start+1);
31
+ }
32
+ return maxLength;
33
+
34
+ }
35
+ };
36
+
37
+ ```
38
+
39
+ # π μ½λ μ€λͺ
40
+
41
+
42
+ # μ΅μ ν ν¬μΈνΈ (Optimality Discussion)
43
+ β’ μ΅μ νν μ΄μ μ μ리
44
+ β’ λ μ€μΌ μ μλ μ¬μ§λ μλκ°?
45
+ β’ κΈ°μ‘΄ λ°©λ² λλΉ μΌλ§λ ν¨μ¨μ μ΄μλμ§
46
+
47
+ # π§ͺ ν
μ€νΈ & μ£μ§ μΌμ΄μ€
48
+
49
+ # π κ΄λ ¨ μ§μ 볡μ΅
50
+
51
+ # π νκ³
52
+
53
+
You canβt perform that action at this time.
0 commit comments