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

×

CRANGIRL - Editorial

Concepts: Z algorithm, String matching

LEVEL: medium-hard

Problem Link:http://www.codechef.com/CRNM2014/problems/CRANGIRL

We can use the Z algorithm to solve this problem in O(|A|) time by running it on the string B#A, which is the concatenation of strings B and A with a character in between which doesn't occur in both B and A.

The algorithm produces an array of Z values in which Z[i] is the longest common prefix length of substring (i, N+M) and complete string B#A. We can process this array in reverse direction to print longest running multiples ending at each value.

This question is marked "community wiki".

asked 11 Feb '14, 04:36

apoorv_j's gravatar image

2★apoorv_j
1158
accept rate: 0%

edited 12 Feb '14, 03:18

admin's gravatar image

0★admin ♦♦
19.6k349497539

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:

×15,198
×1,219
×7

question asked: 11 Feb '14, 04:36

question was seen: 2,489 times

last updated: 12 Feb '14, 03:18