What is the time complexity of the dynamic programming approach for solving the longest common substring problem?

  • O(n log n)
  • O(n)
  • O(n^2)
  • O(n^3)
The time complexity of the dynamic programming approach for the longest common substring problem is O(n^2), where 'n' is the length of the input strings. This is achieved by using a 2D table to store intermediate results and avoiding redundant computations.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *