Posts

Angry professor problem solution

This problem is taken from Hakerrank : A Discrete Mathematics professor has a class of N N students. Frustrated with their lack of discipline, he decides to cancel class if fewer than K K students are present when class starts. Given the arrival time of each student, determine if the class is canceled. Input Format The first line of input contains T T , the number of test cases. Each test case consists of two lines. The first line has two space-separated integers, N N (students in the class) and K K (the cancelation threshold). The second line contains N N space-separated integers ( a 1 , a 2 , … , a N a 1 , a 2 , … , a N ) describing the arrival times for each student. Note: Non-positive arrival times ( a i ≤ 0 a i ≤ 0 ) indicate the student arrived early or on time; positive arrival times ( a i > 0 a i > 0 ) indicate the student arrived a i a i minutes late. Output Format For each test case, print the word YES if the class is canceled or NO if it...

Consonant Reversal solution

Ritika gives  N N  strings to Semona and asks her to perform a  consonant reversal  on each string  S S  such that the indexed positions of its vowels ( a a ,  e e  ,  i i ,  o o , and  u u ) are unchanged but all the consonants are reversed. This means that each vowel must be at the same exact index before and after the reversal. Because the value of  N N  is very large, Semona wants your help accomplishing this with code! Given  N N  strings, reverse and print each string such that the positions of its vowels remain unchanged but all its consonants are reversed. Input Format The first line contains an integer,  N N , the number of strings. Each of the  N N  subsequent lines contains a string,  S S , to be reversed. Constraints 1 ≤ N ≤ 1000 1 ≤ N ≤ 1000 1 ≤ | S i | ≤ 2000 1 ≤ | S i | ≤ 2000 , where  0 ≤ i < N 0 ≤ i < N Each string contains lowercase letters....