You are not logged in. Please login at to post your questions!


whats Making it TLE

asked 10 Jul '18, 00:15

code_man's gravatar image

accept rate: 8%

It depends on complexity of function s.equals(e) which i think is O(min(s.length,e.length)). So your codes complexity turns out to be O(min(s.length,e.length)*s.length). Now for s.length =10^5 Complexity for worst case can be O(10^10).

That's the reason for TLE.


answered 10 Jul '18, 00:26

hrishabh15's gravatar image

accept rate: 33%

What will be the alternative , how can I remove TLE

(10 Jul '18, 00:29) code_man3★

The thing in this question is you can't remove right side of string. So we will start from back of both strings , Lets assume our strings to be "codechef" and "fdhef", During our first iteration 'f' is common in both strings So During the process of removing, this position from strings won't get removed. Same for 'e' and 'h' but now character 'e' and 'd' aren't same So what we do is break he loop as we possibly can't get another character in our answer string. Now what our answer should be is s.length+e.length-2*x. where x is number of same back character we got.

(10 Jul '18, 00:50) hrishabh155★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 10 Jul '18, 00:15

question was seen: 92 times

last updated: 10 Jul '18, 00:50