kamyu104 / LeetCode-Solutions

🏋️ Python / Modern C++ Solutions of All 3292 LeetCode Problems (Weekly Update)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why is the complexity O(N^2) and not O(N)

sparshgarg23 opened this issue · comments

Hello,can you explain why the compexity is O(N^2) and not O(N)

commented

I don't understand which problem you are asking about.
Could you give me more details?

Sure I will get back to you soon with the details

The problem is reverse substrings between each pair of parantheses(C++ )

commented

About "1190. Reverse Substrings Between Each Pair of Parentheses" :

  • I added a real O(n) solution from Leetcode forum.
  • In the 2-pass solution, each character is traversed only once in each pass, so it is O(n).
  • Thanks for your friendly reminder.