String s of lowercase english letters

Assignment Help Basic Computer Science
Reference no: EM13160235

Magic strings, invented by the Bytelandians, are strings that contain immense magical power within themselves. Magic strings could bring luck and happiness to the Bytelandian citizens. Formally, a string S of length n is a magic string if it satisfies the following conditions:

  • All letters of S are lowercase letters of the English alphabet.
  • Si is lexicographically smaller than Sn-i+1 for all odd i from 1 to [n/2].
  • Si is lexicographically greater than Sn-i+1 for all even i from 1 to [n/2].

(Si (1 ? i ? n) denotes the ith character of S). For example, the word "difference" is a magic string, while "similar" is not.

Given a string S of lowercase English letters, write a program to find the longest magic string than can be obtained by removing some letters of S. If there are more than one solutions, choose the longest magic string which is lexicographically smallest.

The first line contains t, the number of test cases (about 10). Then t test cases follow. Each test case contains a string S written in a single line. S does not contain more than 2000 letters.

Reference no: EM13160235

Questions Cloud

Calculate number of unit sale in two different categories : Shopkeeper sale this good on breakeven. Calculate the no of Unit sale in two different categories This is a trading Company.
Common hazards in a healthcare facility : Describe at least five common hazards in a healthcare facility and describe how these hazards can be avoided or addressed in specific healthcare settings
Problem related to financing a new car : You Have saved $4000 for a down payment on a new car. the largest monthly payment you can afford is $350. the loan will have a 12% APR based on end of month payments. what is the most expensive car you can afford if you finance it for 48 months? 6..
How does it relate to national consumption : Why is it important, for an open economy, that investment not be consistently higher than saving? If this occurs how does it relate to national consumption, balance of trade and saving?
String s of lowercase english letters : Given a string S of lowercase English letters, write a program to find the longest magic string than can be obtained by removing some letters of S. If there are more than one solutions, choose the longest magic string which is lexicographically small..
State what is the value of the rate constant for reaction : What is the value of the rate constant (k) for this reaction? Points will be deducted if you do not include the correct sign and units of the rate constant. (b) Determine the half-life for this reaction in units of seconds
Which of lipid pairs is more susceptible tooxidation : Which of the following lipid pairs is more susceptible tooxidation?
Explain why the higher real wage would fail to increase : Assuming that factor markets are otherwise free and competitive, explain why the higher real wage would fail to increase the share of labor income in national income.
An algorithm that will sort a with a worst-case runtime : Let A be an array with n elements such that the first n -sqrt( n) elements are already sorted (though we know nothing about the remaining elements). Give an algorithm that will sort A with a worst-case runtime substantially better than O(n logn).

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Classify occurrences as an incident or disaster

Classify each of the following occurrences as an incident or disaster. If an occurrence is a disaster, determine whether or not business continuity plans would be called into play.

  Why are you normally required to bind a service

What steps need to be taken by a network service to be ready to receive TCP/IP connections? Why are you normally required to bind a service to a specific port?

  How many different seven-digit phone numbers can be formed

How many different seven-digit phone numbers (ignoring area code) can be formed? Can city of 2 million people be served by single area code? Describe.

  Computing effective cpi of computer

Workstation uses a 15-MHZ processor with claimed 10-MIPS rating to execute a given programme mix. Suppose a one-cycle delay for each memory access. Compute effective CPI of this computer ?

  Computing cycles to save if registers are available

Determine the number of cycles will be saved if both registers are available?

  Write structured english for clyde-s narrative policies

Lasting more than one day, we permit hotel, taxi, and airfare, also meal allowances. Same times apply for meal expenses." Write down structured English for Clyde's narrative of reimbursement policies.

  Discuss whether you accept demand from manager

Discuss whether you should accept this demand from your manager or whether you should persuade your team to give their time to the organization rather than to their families. What factors might be significant in your decision?

  Explain dynamic programming approach-longest weighted path

Assume we have a directed acyclic graph G = (V, E) with real-valued edge weights and two distinguished vertices s and t. Explain a dynamic programming approach for ?nding a longest weighted simple path from s to t.

  Convert decimal number in sixteen bit binary

Convert decimal number +25 and +3 in 16-bit binary. Illustrate your work. Add binary numbers in above question using rules for binary addition.

  Compute the cost of sorting the relation in seconds

Suppose a flash storage device is used instead of disk, and it has a seek time of 1 microsecond and a transfer rate of 40 MB per second. Recompute the cost of sorting the relation in seconds with.

  Explain relationship oriented and less transaction oriented

Are geared towards short-term spot purchasing. Are more relationship oriented and less transaction oriented than private industrial networks.

  Explaining laws dealing with computer crimes

Write and explain three recent laws dealing with computer crimes.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd