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

×

SPOJ MINSEQ

my solution to the problem http://www.spoj.com/problems/MINSEQ/ http://ideone.com/2PsjEt i have solved the problem in O(len(a)+len(b)) but getting wrong ans , i have tried all possible test cases ,if possible give me some test cases where the solution fails

asked 15 Oct '14, 23:36

viperx's gravatar image

4★viperx
3114
accept rate: 0%


I think in Line No 44 of your code the reference to a[j] crosses the limits of the string of a. Also your algorithm is not O(len(a) + len(b)). It is (len(a) * len(b)) if all the characters are same in both the strings. Then anyway it will suffer from TLE. I think the problem can be solved using KMP.

link

answered 27 Oct '14, 20:50

thenextgen's gravatar image

4★thenextgen
261
accept rate: 0%

thanks :-)

link

answered 28 Oct '14, 22:56

viperx's gravatar image

4★viperx
3114
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×1,101

question asked: 15 Oct '14, 23:36

question was seen: 997 times

last updated: 29 Oct '14, 19:26

Related questions