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

×

Substring Query

SUBQUERY

I am trying to solve this problem but I have a confusion regarding substrings to consider. For example, if string is aabbcccaabbbccc and we want to count the number of substrings of length=2 that occur P=2 times. Should we consider bb and cc in the count?

asked 29 Jul '17, 10:46

singh_vikram's gravatar image

4★singh_vikram
11
accept rate: 0%


I dont think so. Considering two substrings same if and only if both their starting and ending indices are same, I will say "bb" occurs 2 times in "bbb" as a substring and 1 more time at start, so it occurs for a total of 3 times.

link

answered 29 Jul '17, 10:54

vijju123's gravatar image

5★vijju123 ♦♦
15.5k12066
accept rate: 18%

But I checked successful solution for the input aabbcccaabbbccc
1
2 2

The output is 3

(29 Jul '17, 12:11) singh_vikram4★

I think this Q is taking things this way, "aa" "aa" is first 1, then "bb" and first 2 b's in "bbb" as 2nd substring, (i.e. breaking "bbb" as "bb"[this substring is counted] +"b") and so on. But i myself kind of disagree with this. I hope someone else is able to help you better :)

(29 Jul '17, 12:48) vijju123 ♦♦5★
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:

×643
×38

question asked: 29 Jul '17, 10:46

question was seen: 436 times

last updated: 29 Jul '17, 13:16