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


CRANGIRL - Editorial

Concepts: Z algorithm, String matching

LEVEL: medium-hard

Problem Link:

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

accept rate: 0%

edited 12 Feb '14, 03:18

admin's gravatar image

0★admin ♦♦

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: 11 Feb '14, 04:36

question was seen: 2,489 times

last updated: 12 Feb '14, 03:18