Posts

Showing posts from July, 2020

Number of Divisors | HackerEarth

Given a number  N , find the total number of divisors of  N . Input: First-line contains a number of test cases  T . Each test case contains a single integer  N . Output: For each test case print number of divisors of  N . Constraints: Test Files 1 to 5 1<= T <=20 1<= N <=1000000 Test Files 6 to 10 1<= T <=1000 1<= N <=10 12 Sample Input 3 4 5 6 Sample Output 3 2 4

CamelCase | HackerRank Problem Solving

Alice wrote a sequence of words in CamelCase as a string of letters,  , having the following properties: It is a concatenation of one or more  words  consisting of English letters. All letters in the first word are  lowercase . For each of the subsequent words, the first letter is  uppercase  and rest of the letters are  lowercase . Given  , print the number of words in   on a new line. For example,  . There are   words in the string. Function Description Complete the  camelcase  function in the editor below. It must return the integer number of words in the input string. camelcase has the following parameter(s): s : the string to analyze Input Format A single line containing string  . Constraints Output Format Print the number of words in string  . Sample Input saveChangesInTheEditor Sample Output 5 Explanation String   contains five words: save Changes In The Editor Thus, we print ...

Micro and Queue | HackerEarth

Micro just purchased a queue and wants to perform  N  operations on the queue. The operations are of the following type: E   x  : Enqueue  x  in the queue and print the new size of the queue. D : Dequeue from the queue and print the element that is deleted and the new size of the queue separated by space. If there is no element in the queue then print  1  in place of the deleted element. Since Micro is new with a queue data structure, he needs your help. Input: First-line consists of a single integer denoting  N Each of the following  N  lines contains one of the operations as described above. Output: For each enqueues operation print the new size of the queue. And for each dequeue operation, print two integers deleted element ( 1 , if the queue is empty) and the new size of the queue. Constraints: 1 ≤ N ≤ 100 1 ≤ x ≤ 100 Input 5 E 2 D D E 3 D Output 5 E 2 D D E 3 D

Fun Game | HackerEarth

A and  B   are playing a game. In this game, both of them are initially provided with a  list of  n numbers . (Both have the same list but their own copy). Now, they both have a different strategy to play the game.  A  picks the element from the  start of his list .   B  picks from the  end of his list . You need to generate the result in the form of an output list. Method to be followed at each step to build the output list is: If the number picked by  A  is bigger than  B   then this step's  output is  1   .  B   removes  the number that was picked from their list. If the number picked by  A  is smaller than  B   then this step's  output is  2   .  A  removes  the number that was picked from their list. If both have the  same number  then this step's  output is  0   .  Both  A ...