title-img


Similar Strings

Jimmy loves playing with strings. He thinks string A is similar to string B if the following conditions are satisfied: Both strings have the same length (i.e., and ). For each valid pair of indices, , in the strings, and or and . For example, string and are similar as for , and and for all other pairs as well as . He has a string, , of size and gives you queries to answer where each query is in the form of a pair of integers . For each substring , find the number of substrin

View Solution →

Save Humanity

Oh!! Mankind is in trouble again. This time, it's a deadly disease spreading at a rate never seen before. The need of the hour is to set up efficient virus detectors. You are the lead at Central Hospital and you need to find a fast and reliable way to detect the footprints of the virus DNA in that of the patient. The DNA of the patient as well as of the virus consists of lowercase letters. Since the collected data is raw, there may be some errors. You will need to find all substrings in the p

View Solution →

Find Strings

A substring is defined as a contiguous sequence of one or more characters in the string. More information on substrings can be found here. You are given n strings w[1], w[2], ......, w[n]. Let S[i] denote the set of all distinct substrings of the string w[i]. Let , that is, S is a set of strings that is the union of all substrings in all sets S[1], S[2], ..... S[n]. There will be many queries. For each query you will be given an integer 'k'. Your task is to find the kth element of the -indexe

View Solution →

Palindromic Border

A border of a string is a proper prefix of it that is also a suffix. For example: a and abra are borders of abracadabra, kan and kankan are borders of kankankan. de is a border of decode. Note that decode is not a border of decode because it's not proper. A palindromic border is a border that is palindromic. For example, a and ana are palindromic borders of anabanana, l, lol and lolol are palindromic borders of lololol. Let's define as the number of palindromic borders of string .

View Solution →

Two Two

Prof. Twotwo as the name suggests is very fond powers of 2. Moreover he also has special affinity to number 800. He is known for carrying quirky experiments on powers of 2. One day he played a game in his class. He brought some number plates on each of which a digit from 0 to 9 is written. He made students stand in a row and gave a number plate to each of the student. Now turn by turn, he called for some students who are standing continuously in the row say from index i to index j (i<=j) and

View Solution →