Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 43141e9

Browse files
committedMay 23, 2017
3
1 parent ee92b8c commit 43141e9

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed
 

‎README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ Success is like pregnancy, Everybody congratulates you but nobody knows how many
1111
## Linked List
1212
[Overview](http://www.cnblogs.com/Raising-Sun/p/5970662.html#3534606)
1313

14-
14+
## Array
15+
| # | Title | Solution | Time | Space | Difficulty | Note|
16+
|-----|-------| -------- | ---- | ------|------------|-----|
17+
|3| [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/#/solutions) | [Python](./array/3.py) | _O(n)_| _O(n)_ | Medium | Hash table|
1518

1619
## Linked List Easy
1720
| # | Title | Solution | Time | Space | Difficulty |Tag| Note|
@@ -94,7 +97,6 @@ Success is like pregnancy, Everybody congratulates you but nobody knows how many
9497
|46|[Permutations](https://leetcode.com/problems/permutations/#/description)| [Python [Yu]](./backtrack/Yu/46.py) | _O(N*(N!))_| _O(N!)_ | Medium | |[公瑾讲解](https://www.youtube.com/watch?v=oCGMwvKUQ_I&feature=youtu.be)|
9598
|47|[Permutations II](https://leetcode.com/problems/permutations/#/description)| [Python [Yu]](./backtrack/Yu/47.py) | _O(N*(N!))_| _O(N!)_ | Medium | |[公瑾讲解](https://youtu.be/imLl2s9Ujis)|
9699
|60|[Permutation Sequence](https://leetcode.com/problems/permutation-sequence/#/description)| [Python [Yu]](./backtrack/Yu/60.py) | _O(N * (N!)_| _O(N)_ | Medium | ||
97-
98100
|77|[Combinations](https://leetcode.com/problems/combinations/#/description)| [Python [Yu]](./backtrack/Yu/77.py) | _O(N*(N!))_| _O(N!)_ | Medium | ||
99101
|39|[Combination Sum](https://leetcode.com/problems/combination-sum/#/description)| [Python [Yu]](./backtrack/Yu/39.py) | _O(K * (2^N)_| _O(N)_ | Medium | |[公瑾讲解](https://youtu.be/HdS5dOaz-mk)|
100102
|40|[Combination Sum II](https://leetcode.com/problems/combination-sum-ii/#/solutions)| [Python [Yu]](./backtrack/Yu/39.py) | _O(K * (2^N)_| _O(N)_ | Medium | |[公瑾讲解](https://youtu.be/HdS5dOaz-mk)|

‎array/3.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution(object):
2+
def lengthOfLongestSubstring(self, s):
3+
"""
4+
:type s: str
5+
:rtype: int
6+
"""
7+
#Edge
8+
if not s:
9+
return 0
10+
11+
start, max_length, hash = 0, 0, {}
12+
13+
for i, num in enumerate(s):
14+
# Need to have the following condition:
15+
# start <= hash[num] to avoid edge case such as :
16+
# "tmmzuxt"
17+
if num in hash and start <= hash[num]:
18+
#update pointer
19+
start = hash[num] + 1
20+
else:
21+
max_length = max(max_length, i - start + 1)
22+
23+
hash[num] = i
24+
25+
return max_length

‎try.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
meh = xrange(0, 10)
2-
print len(meh)
1+
# Creates a list containing 5 lists, each of 8 items, all set to 0
2+
n = 6;
3+
Matrix = [["." for x in range(n)] for y in range(n)]
4+
string = ','.join(Matrix)
5+
6+
#print Matrix
7+
print string

0 commit comments

Comments
 (0)
Please sign in to comment.