Kaynağa Gözat

Add complexity analysis

Snow 8 yıl önce
ebeveyn
işleme
8ebf3fcca3
1 değiştirilmiş dosya ile 4 ekleme ve 0 silme
  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():