Browse Source

Add complexity analysis

Snow 8 years ago
parent
commit
8ebf3fcca3
1 changed files with 4 additions and 0 deletions
  1. 4 0
      arrays-and-strings/longest_substring.py

+ 4 - 0
arrays-and-strings/longest_substring.py

@@ -1,4 +1,8 @@
 # Given a string, find the length of the longest substring without repeating characters.
+# Time complexity: worst O(n^2), best O(n). Using hash table to check unique
+# reduces to always O(n^2)
+# Space complexity: O(n/2)
+
 import pytest
 
 def test_longest_substring():