Posts

Showing posts from June, 2020

String Validator problem solution |PYTHON| HackerRank

Task:- You are given a string . Your task is to find out if the string  contains: alphanumeric characters, alphabetical characters, digits, lowercase and uppercase characters. Input Format:- A single line containing a string . Constraints:- 0 < len(S) < 1000 Output Format In the first line, print True if  has any alphanumeric characters. Otherwise, print False. In the second line, print True if  has any alphabetical characters. Otherwise, print False. In the third line, print True if  has any digits. Otherwise, print False. In the fourth line, print True if  has any lowercase characters. Otherwise, print False. In the fifth line, print True if  has any uppercase characters. Otherwise, print False. Sample Input  qA2 Sample Output True True True True True Solution :-                                      1.    Note:--  code is in Python 3 n ...

List problem solution |PYTHON| HackerRank

OVERVIEW:-     Consider a list (list = []). You can perform the following commands:---->> insert i e: Insert integer  at position . print: Print the list. remove e: Delete the first occurrence of integer . append e: Insert integer  at the end of the list. sort: Sort the list. pop: Pop the last element from the list. reverse: Reverse the list. Initialize your list and read in the value of  followed by  lines of commands  where each command will be of the  types listed above. Iterate through  each command in order and perform the corresponding operation on your list. Input Format:-     The first line contains integer ,N , denoting number of commands . Each line i of the N subsequent lines contains one of the commands decribed above. Output Format:- For each command of type print , print the list on a new line.   Constraints:-    The elements added to the list will be an integer.  Sample Input :- 12 inse...

Recursion 3 Problem solution | 30 days of code| Hacker Rank

Task:-     Write a factorial function that takes positive integer , N , as paramater and prints                 the result of N! ( N factorial ). Note:-     If you fail to use recursion of fail to name your recursive function factorial or                Factorial , you will get a score of a 0.    Input Format:-   A single integer , N ( the argument to pass to factorial ). Constraints:-  >    2 <= N <= 12  >    Your submission must contain recursive function having named factorial. Output Format:-  Print a single integer denoting N!. Sample Input:-          3 Sample Output:-        6       Solution Code:-                   Note:--   Code is in Java. import java.io.*; import java.math.*; import java.security.*; ...

Nested lists problem solution | Python | HackerRank

Input Format:-     The first line take input N, Which denote the number of student.     The 2N subsequent lines describe each student over 2 lines ; and the first line contain name of student ,      and  on second line it contain grade of that student. Constraints:-  >    2 <= N <= 5   >    There will always be one or more student to have the second lowest grade.  Output Format:-  Print the name(s) of any student(s) having the second lowest grade in Physics: if there are multiple students,order their name in a order of alphabetically and print each one on  new line.             Solution Code:-                  Note:--   Code is for Python 3              n = int(input())              data = list()           ...