Posts

Showing posts with the label codechef

Isolation Centers

Image
  Problem Link: Codechef As a health expert, Vinay is keeping a close watch on the ongoing pandemic of coronavirus disease (COVID-19). He thought of a different situation where there are  26 26  types of viruses, named " a orona", " b orona", " c orona", …, " z orona". You are given a string  S S  with length  N N . There are  N N  people (numbered  1 1  through  N N ) and for each valid  i i , the  i i -th person is infected by exactly one type of virus named  S i Si orona (i.e. "corona" with the first letter replaced by the  i i -th character of  S S ). You should answer  Q Q  queries. In each query: ·        You are given an integer,  C C  denoting the number of available  isolation centers . ·        Each isolation center has an infinite capacity, but with the restriction that two people infected with the same ty...

Bharath and his strings

Image
  Problem link:  Codechef Bharath loves to roam the campus of NITW and also he is good at problem-solving. Pratyush decided to give a problem to Bharath. Pratyush gives Bharath a list of places inside NITW (each place is represented by some character from 'a' to 'z'). Starting from the beginning, Bharath has to visit all the places in the same order as given in the list. While roaming Bharath writes the name of a place when he visits it for the first time. At the end of the day, Bharat will tell all the distinct places traveled by him during the entire day in the order he visited them. Input First-line will contain T, the number of test cases. The description of T test cases follows. The first and only line of each test case contains a string S (containing only lowercase alphabets). Output For each test case print the order of visit of Bharath. Constraints ·        1  <=  T  <=  10 ·    ...

Lapindromes

Image
  Problem link:  Codechef Lapindrome  is defined as a string which when split in the middle, gives two halves having the same characters and the same frequency of each character. If there are an odd number of characters in the string, we ignore the middle character and check for lapindrome. For example,  gaga  is a lapindrome, since the two halves  ga  and  ga  have the same characters with the same frequency. Also,  abccab ,  rotor,  and  xyzxy  are a few examples of lapindromes. Note that  abbaab  is NOT a lapindrome. The two halves contain the same characters but their frequencies do not match. Your task is simple. Given a string, you need to tell if it is a lapindrome. Input: The first line of input contains a single integer  T , the number of test cases. Each test is a single line containing a string  S  composed of only lowercase English alphabet. Output: For each test case, ...