What is the time complexity of the brute-force approach for finding the Longest Palindromic Substring?

  • O(log n)
  • O(n log n)
  • O(n)
  • O(n^2)
The time complexity of the brute-force approach for finding the Longest Palindromic Substring is O(n^2), where 'n' is the length of the input string. This is because it involves nested loops to explore all possible substrings.
Add your answer
Loading...

Leave a comment

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