Problem 1: Program to display Fibonacci Series.
Input: How Many Terms do you want to Display: 10
Output: 0 1 1 2 3 5 8 13 21 34
Problem 2: Program to find Factorial of number.
Input: Enter a Number: 5
Output: 5! = 120
Problem 3: Program to find HCF of numbers.
Input: Enter 1st Number: 5
Enter 2nd Number: 12
Output: HCF: 1
Problem 4: Program to find LCM of numbers.
Input: Enter 1st Number: 5
Enter 2nd Number: 12
Output: LCM: 1
Input: Enter a Number: 78
Output: It's not an Fibonacci Number
Input: Enter a Number: 55
Output: Yup! It's a Fibinacci Number
Input: Enter a Number: 189
Output: No, It's not an Armstrong Number
Input: Enter a Number: 153
Output: It's an Armstrong Number
Problem 2: Program for Array Rotation.
Input: [ 5, 6, 7, 8, 1, 11, 15, 16], N = 4
Output: [1, 11, 15, 16, 5, 6, 7, 8]
Input: [5, 7, 9, 4, 6, 23, 11, 12]
Output: Max: 23, MIN: 4
Input: Enter a Number: 121
Output: Palindrome Number
Input: Enter a Number: 123
Output: Not a Palindrome Number
Input: Upto How Many Terms: 20
Output: 2 3 5 7 11 13 17 19
Input: [5, 6, 7, 9, 1, 10, 25, 31]
Output: No, It's not an Monotonic List
Input: [1, 2, 3, 4, 5, 6, 7, 8]
Output: Yup, It's an Monotonic List
Problem 2: Program for Reversing a list.
Input: [7, 4, 5, 6, 7, 8, 9, 1]
Output: [1, 9, 8, 7, 6, 5, 4, 7]
Problem 3: Program for Searching elements in a list.
Input: [7, 6, 5, 3, 2, 6, 5, 10], N = 6
Output: Present
Input: [7, 6, 5, 3, 2, 6, 5, 10]
Output: Second Largest Element is: 7
Input: [10, 5, 2, 6, 3, 7, 9, 4]
Output: [4, 5, 2, 6, 3, 7, 9, 10]
Problem 1: Program for Cloning/Copying the list.
Input: [4, 5, 7, 8, 9, 6, 10, 15]
Output: [4, 5, 7, 8, 9, 6, 10, 15]
Problem 2: Program for N Largest elements in a list.
Input: [4, 5, 7, 8, 9, 6, 10, 15]
Output: [15, 10, 9, 8]
Problem 3: Program for Occurrences of elements.
Input: [14, 25, 16, 23, 10, 5, 6, 8, 7, 9, 10, 25, 14], N = 14
Output: 14 Occurs 2 times
Problem 4: Program for Removing Empty list.
Input: [5, 6, [], 7, 8, 9, [], 12, [], 4,[]]
Output: [5, 6, 7, 8, 9, 12, 4]
Problem 5: Program for Removing Multiple Elements.
Input: [1, 2, 3, 4, 5], N = [2, 4]
Output: [1, 3, 5]
Problem 1: Program to Break list into Chunks of list.
Input: [10, 45, 20, 62, 47, 85, 12, 63, 24, 78, 10], N = 2
Output: [[45, 20], [62, 47], [85, 12], [63, 24], [78, 10]]
Problem 2: Program for Cumulative Sum of list.
Input: [10, 20, 30, 40, 50, 60]
Output: [10, 30, 60, 100, 150, 210]
Problem 3: Program to print Duplicates in list.
Input: [4, 5, 1, 2, 6, 5, 2]
Output: [5, 2]
Problem 4: Program for Flattening a list.
Input: [1, 2, [3, 4, [5, 6], 7], [[[8, 9], 10]], [11, [12, 13]]]
Output: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
Problem 1: Program for Increamenting Numeric String.
Input: ["100", "Days", "of", "CodeChallenge", "234", "is", "98", "123", "best", "4"], N = 10
Output: ['110', 'Days', 'of', 'CodeChallenge', '244', 'is', '108', '133', 'best', '14']
Problem 2: Program to find Maximum of each key in list.
Input: [{"Days": 8, "Code": 1, "Challenge": 9}, {
"Days": 2, "Code": 9, "Challenge": 1}, {"Days": 5, "Code": 10, "Challenge": 7}]
Output: {'Days': 8, 'Code': 10, 'Challenge': 9}
Problem 3: Program to Sort list_1 by list_2.
Input: ["a", "b", "c", "d", "e", "f", "g", "h", "i"], [0, 1, 1, 0, 1, 2, 2, 0, 1]
Output: ['a', 'd', 'h', 'b', 'c', 'e', 'i', 'f', 'g']
Problem 4: Program for Words Reverse Pairs in list.
Input: ["skeeg", "best", "tseb", "for", "skeeg", "skeeg", "best", "geeks", "tseb"]
Output: 3 Reverse Pairs
Problem 1: Program to Remove Row with custom elements.
Input: Test_list = [[5, 3, 1], [7, 8, 9], [1, 10, 22], [12, 18, 21]], N = [3, 10, 19, 29, 20, 15]
Output: [[7, 8, 9], [12, 18, 21]]
Input: [343, 893, 1948, 3433333, 2346], N = 3
Output: ['4', '89', '1948', '4', '246']
Problem 3: Program to print strings Based on Prefix.
Input: Test_list = ["geeks", "peeks", "meeks", "leeks", "mean"], Prefix_list = ["ge", "ne", "me", "re"]
Output: ['geeks', 'meeks', 'mean']
Problem 4: Program to Swap ith with jth element.
Input: Test_list = [4, 7, 8, 0, 8, 4, 2, 9, 4, 8, 4], i, j = 4, 8
Output: [8, 7, 4, 0, 4, 8, 2, 9, 8, 4, 8]
Input: Test_list = [4, 24, 8, 10, 12, 23], Check_list = [6, 4]
Output: [24, 12]
Input: ["gfg", "beaeioust", "for", "geeks"]
Output: beaeioust
Input: Test_list = [4, 5, 6, 4, 1, 4, 8, 5, 4, 3, 4, 9], i, j = 4, 8
Output: 4 Occurs 3 times before 8 Occur
Problem 4: Program to Sort Row by frequency of key.
Input: [[10, 2, 3, 2, 3], [5, 5, 4, 7, 7, 4], [1, 2], [1, 1, 2, 2, 2]], n = 2
Output: [[5, 5, 4, 7, 7, 4], [1, 2], [10, 2, 3, 2, 3], [1, 1, 2, 2, 2]]
Problem 1: Program to Add Two Matrix.
Input: X = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
Y = [[9, 8, 7],
[6, 5, 4],
[3, 2, 1]]
Output: [10, 10, 10, 10, 10, 10, 10, 10, 10]
Problem 2: Program to Multiply Two Matrix.
Input: A = [[12, 7, 3], [4, 5, 6], [7, 8, 9]], B = [[5, 8, 1, 2], [6, 7, 3, 0], [4, 5, 9, 1]]
Output: [[114, 160, 60, 27], [74, 97, 73, 14], [119, 157, 112, 23]]
Input: [[1, 4, 5], [7, 3], [4], [46, 7, 3]]
Output: 1622880
Problem 4: Program to Transpose a Matrix.
Input: [[12, 7], [4, 5], [3, 8]]
Output: [12, 4, 3]
[7, 5, 8]
Problem 1: Program for Kth Element in Matrix.
Input: Test_list = [[4, 5, 6],
[8, 1, 10],
[7, 12, 5]]
K = 2
Output: [5, 1, 12]
Problem 1: Program for String Palindrome.
Input: amma
Output: Palindrome String
Input: code
Output: Not a Palindrome String
Input: amam
Output: Symmetric and Not Palindrome
Input: amaama
Output: Symmetric and Palindrome
Input: [["Gfg", "good"], ["is", "for"], ["Best"]]
Output: ['GfgisBest', 'goodfor', '']
Problem 1: Program to Remove Duplicates from a List.
Input: [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]
Output: [1, 2, 3, 4, 5, 6]
Problem 2: Program to Remove Particular Character.
Input: Hey! There satyam here, K = !
Output: Hey There satyam here
Problem 3: Program to Reverse Words of string.
Input: 100 Days of Code Challenge
Output: Challenge Code of Days 100
Input: 100 days of code challenge
Output: 100DaysOfCodeChallenge
Problem 5: Program to Find word with Maximum Frequency.
Input: hey you yeah you where are you
Output: you
Problem 1: Program for Even length String.
Input: 100 Days of Code Challenge
Output: Days, of, Code
Problem 2: Program for least Frequency Character.
Input: this is github challenge
Output: u
Problem 3: Program for Matching Characters in string.
Input: F1 = 100 Days of Code Challenge, F2 = Code Challenge
Output: Code Challenge
Problem 4: Program to print String with Vowels.
Input: Github Challenge
Output: Not Accepted
Input: aaoaao
Output: Accepted
Input: Code Challenge, K = 6
Output: Code Callenge
Problem 2: Program for Special Characters in string.
Input: github@io
Output: Not Accepted
Input: githubio
Output: Accepted
Input: 123456
Output: Not a Binary
Input: 1011001011
Output: Binary
Input: Hey! this is 100 Days of Code Challenge, N = 4
Output: Challenge
Problem 1: Program for PERMUTATION of string.
Input: ABC
Output: ABC, ACB, BAC, BCA, CAB, CBA
Input: Hey! this is 100 Days of Code Challenge, N = 4
Output: Challenge
Input: Hey! this is 100 Days of Code Challenge, N = 4
Output: Challenge
Problem 4: Program to print Uncommon Words in strings.
Input: Hey! this is 100 Days of Code Challenge, N = 4
Output: Challenge
Problem 1: Program for Executing a String of Code.
Input: Test_string = """
def factorial(num):
fact=1
for i in range(1,num+1):
fact = fact*i
return fact
print(factorial(5))
"""
N = 5
Output: 120
Problem 2: Program for checking URL in String.
Input: "These are the links http://www.google.com and http://stackoverflow.com/questions/839994/extracting-a-url-in-python"
Output: http://www.google.com
http://stackoverflow.com/questions/839994/extracting-a-url-in-python
Input: Hey! There this is 100 Days of Code Challenge
Output: Left Rotation: There this is 100 Days of Code ChallengeHey!
Right Rotation: engeHey! There this is 100 Days of Code Chall
Input: a = CoCodede, b = Code
Output: True
Input: Test_string = "@geeksfor#geeks123%^&*"
Test_list = ['#', '%', '8', '@', ')']
Output: [True, True, False, True, False]
Problem 2: Program for Duplicates Characters in string.
Input: hey this is Github Repo
Output: hey tis
Input: ['John Wick', 'Jason Voorhees', 'Freddy Krueger', 'Keyser Soze', 'Mohinder Singh Pandher']
Output: ['Freddy Krueger', 'Mohinder Singh Pandher', 'Keyser Soze', 'Jason Voorhees', 'John Wick']
Input: 1st String: Hey this is Code Challenge
2nd String: wait this is Github Repo
Output: C R p u d n G l g y H b w
Problem 1: Program for Maximum UpperCase run.
Input: GeEKSforGEEKSISBESt
Output: GEEKSISBES 10
Input: This is 100 Days of Code Challenge Plus 50 Days Also
Output: This is Days of Code Challenge Plus Days Also10050
Input: String: This is 50 Days of Code Challenge
Which: 50
To: 100
Output: This is 100 Days of Code Challenge
Problem 4: Program to print strings based on Prefix.
Input: Test_list = ["geeks", "peeks", "meeks", "leeks", "mean"]
Pref_list = ["ge", "ne", "me", "re"]
Output: geeks meeks mean
Problem 1: Extracting Values from Dictionary.
Input: Test_dict = {'Challenges': [5, 6, 7, 8],
'are': [10, 11, 7, 5],
'best': [6, 12, 10, 8],
'for': [1, 2, 5]}
Output: [1, 2, 5, 6, 7, 8, 10, 11, 12]
Problem 2: Remove a Key from Dictionary.
Input: {'This': 12, 'is': 24, 'Code': 36, 'Challenge': 48, 'Github': 60}
Which Key to Delete: Github
Output: {'This': 12, 'is': 24, 'Code': 36, 'Challenge': 48}
Input: Test_list = [{"Name": "Tushar", "Age": 20},
{"Name": "Aditya", "Age": 19},
{"Name": "Satyam", "Age": 21}]
Output: Age Sorting: [{'Name': 'Aditya', 'Age': 19}, {'Name': 'Tushar', 'Age': 20}, {'Name': 'Satyam', 'Age': 21}]
Name and Age Sorting: [{'Name': 'Aditya', 'Age': 19}, {'Name': 'Tushar', 'Age': 20}, {'Name': 'Satyam', 'Age': 21}]
Problem 4: Find the Sum of all items in a Dictionary.
Input: {'a': 100, 'b': 200, 'c': 300, 'd': 400}
Output: Total Sum: 1000
Input: Enter String: CodeChallenge
Enter Pattern: Co
Output: True
Input: Enter String: CodeChallenge
Enter Pattern: oC
Output: False
Input: Test_dict = {'Month': [1, 2, 3],
'Name': ['Jan', 'Feb', 'March']}
Output: Total Sum: {1: 'Jan', 2: 'Feb', 3: 'March'}
Problem 3: Program for Merging Two Dictionaries.
Input: Test_dict_1 = {'A': 10, 'B': 8}
Test_dict_2 = {'D': 6, 'C': 4}
Output: {'A': 10, 'B': 8, 'D': 6, 'C': 4}
Input: Test_list = [{"Name": "Satyam", "Age": 20},
{"Name": "Aditya", "Age": 20},
{"Name": "Tushar", "Age": 19}]
Output: [{'Name': 'Tushar', 'Age': 19}, {'Name': 'Satyam', 'Age': 20}, {'Name': 'Aditya', 'Age': 20}]
Input: {"Code": 1, "Challenge": 10, "is": 100, "Best": 1000}
Output: ['Code', 'Challenge', 'is', 'Best', 1, 10, 100, 1000]
Input: Test_list = ['john', 'johnny', 'jackie', 'johnny', 'john', 'jackie',
'jamie', 'jamie', 'john', 'johnny', 'jamie', 'johnny', 'john']
Output: john
Input: {'Code': [7, 6, 3], 'Challenge': [2, 10, 3], 'is': [19, 4], 'Best': [18, 20, 7]}
Output: {'Best': [7, 18, 20], 'Challenge': [2, 3, 10], 'Code': [3, 6, 7], 'is': [4, 19]}
Input: {2: 56, 1: 2, 5: 12, 4: 24, 6: 18, 3: 323}
Output: Sorting by Keys: {1: 2, 2: 56, 3: 323, 4: 24, 5: 12, 6: 18}
Sorting by Values: {1: 2, 5: 12, 6: 18, 4: 24, 2: 56, 3: 323}
Input: ['cat', 'dog', 'tac', 'god', 'act']
Output: cat tac act dog god
Input: 8, 4
Output: True, because both have same number of 0's and 1's
Input: {'a': 1, 'b': 2}), key = d
Output: Key not found...
Input: CodeChallenge, K = 2
Output: d, because ['o', 'd', 'h', 'a', 'n', 'g'] ---> This is the list of Non-Repeating Characters in the Given String
Input: [1, 1, 1, 5, 5, 3, 1, 3, 3, 1, 4, 4, 4, 2, 2, 2, 2]
Output: 1 : 5, 5 : 2, 3 : 3, 4 : 3, 2 : 4
Input: codechallenge, K = 4
Output: codvxszoovmtv
Input: Coding is great and challenges is great
Output: Coding is great and challenges
Input: magenta magnate tan gnamate
Output: 3
Input: s1 = ABHISHEKsinGH
s2 = gfhfBHkooIHnfndSHEKsiAnG
Output: Possible
Input: s1 = Hello
s2 = dnaKfhelddf
Output: Not Possible
Input: s1 = GeeksforGeeks
s2 = rteksfoGrdsskGeggehes
Output: Possible
Input: xxxyyzz
Output: True
Input: xxxxyyzz
Output: False
Input: {'Code': [1, 2, 3], "Challenge": [3, 4, 5], 'is': [1, 4], 'best': [4, 2]}
Output: {1: ['Code', 'is'], 2: ['Code', 'best'], 3: ['Code', 'Challenge'], 4: ['Challenge', 'is', 'best'], 5: ['Challenge']}
Input: Test_list = ['go', 'bat', 'me', 'eat', 'goal', 'boy', 'run']
Test_chars = ['e', 'o', 'b', 'a', 'm', 'g', 'l']
Output: go, me, goal
Input: {"Challenges": [5, 3, 6, 3], "are": [1, 7, 5, 3], "Best": [9, 1, 3, 5]}
Output: {'Challenges': 2, 'are': 1, 'Best': 0}
Problem 2: Program for Index Directory of Elements.
Input: [7, 6, 3, 7, 8, 3, 6, 7, 8]
Output: {8: [4, 8], 3: [2, 5], 6: [1, 6], 7: [0, 3, 7]}
Problem 3: Program for Minimum Value Key Assignment.
Input: Test_dict_1 = {"Code": 1, "Challenge": 7, "is": 8, "Best": 10}
Test_dict_2 = {"Code": 5, "Challenge": 5, "is": 7, "Best": 14}
Output: {'Code': 1, 'Challenge': 5, 'is': 7, 'Best': 10}
Problem 4: Program for Shuffling Dictionary Values.
Input: {"Code": 1, "Challenge": 7, "is": 8, "Best": 10}
Output: {'Code': 10, 'Challenge': 8, 'is': 1, 'Best': 7}
Input: {'S': 2, 'a': 3, 'm': 1, 't': 4, 'y': 1, 'y': 4, 't': 3}
Output: ['S', 'S', 'a', 'a', 'a', 'm', 't', 't', 't', 'y', 'y', 'y', 'y']
Input: Test_list = [{"Gfg": 3, "is": 5, "best": 10},
{"Gfg": 5, "is": 1, "best": 1},
{"Gfg": 8, "is": 3, "best": 9},
{"Gfg": 9, "is": 9, "best": 8},
{"Gfg": 4, "is": 10, "best": 7}]
Output: [{'Gfg': 5, 'is': 1, 'best': 1}, {'Gfg': 8, 'is': 3, 'best': 9}, {'Gfg': 9, 'is': 9, 'best': 8}]
Input: {'All': ['All', 'Time', 'Favourite'], 'Favourite': ['All'], 'Code': ['Challenge']}
Output: {'All': ['All', 'Time', 'Favourite'], 'Code': ['Challenge']}
Problem 4: Program for Unique values count of each Key.
Input: Test_dict = [{"Challenges": 1, "are": 3, "Best": 2}, {
"Challenges": 1, "are": 3, "Best": 6}, {"Challenges": 7, "are": 3, "Best": 10}]
Output: {'Challenges': 2, 'are': 1, 'Best': 3}
Input: [2323, 82, 129388, 234, 95]
Output: {23: 23, 8: 2, 129: 388, 2: 34, 9: 5}
Problem 2: Program to Resize keys in Dictionary.
Input: {"geeksforgeeks": 3, "best": 3, "coding": 4, "practice": 3}, K = 2
Output: {'ge': 3, 'be': 3, 'co': 4, 'pr': 3}
Problem 3: Program for Rotating Dictionary by K.
Input: {1: 6, 8: 1, 9: 3, 10: 8, 12: 6, 4: 9}, K = 2
Output: {12: 6, 4: 9, 1: 6, 8: 1, 9: 3, 10: 8}
Input: {5: 3, 1: 3, 10: 4, 7: 3, 8: 1, 9: 5}
Output: False, because Sum of all the Values is less than sum of all the Keys.
Problem 1: Program to Extract digits from Tuple list.
Inpu: [(15, 3), (3, 9), (1, 10), (99, 2)]
Output: [5, 9, 2, 1, 3, 0]
Inpu: [(5, 6), (5, 7), (6, 8), (6, 10), (7, 13)]
Output: [(5, 6, 7), (6, 8, 10), (7, 13)]
Inpu: (5, 20, 3, 7, 6, 8, 2, 87, 9, 14), K = 2
Output: (2, 3, 20, 87)
Problem 4: Program to Find the size of a Tuple.
Inpu: Tuple_1 = ("A", 1, "B", 2, "C", 3)
Tuple_2 = ("Geek1", "Satyam", "hey you yeah you", "Tushar", "Geek3", "Aditya")
Tuple_3 = ((1, "Lion"), (2, "Tiger"), (3, "Fox"), (4, "Wolf"))
Output: Size of Tuple_1: 44 bytes
Size of Tuple_2: 44 bytes
Size of Tuple_3: 36 bytes
Inpu: "ABBBBCCCCCCCCAB"
Output: 1A4B8C1A1B
Inpu: (4, 5), (7, 8)
Output: [(4, 7), (4, 8), (5, 7), (5, 8), (7, 4), (7, 5), (8, 4), (8, 5)]
Problem 3: Program to Remove Tuples of Length K.
Inpu: [(4, 5), (4, ), (8, 6, 7), (1, ), (3, 4, 6, 7)], K = 3
Output: [(4, 5), (4,), (1,), (3, 4, 6, 7)]
Inpu: [('for', 24), ('is', 10), ('Geeks', 28), ('Geeksforgeeks', 5), ('portal', 20), ('a', 15)]
Output: [('Geeksforgeeks', 5), ('is', 10), ('a', 15), ('portal', 20), ('for', 24), ('Geeks', 28)]
Problem 1: Program for Inverted Number Pattern.
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Problem 2: Program for Inverted Star Pattern.
* * * * * *
* * * * *
* * * *
* * *
* *
*
Input: 2000
Output: [2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048, 2052, 2056]
Sample Input Expected Output
heads-150 legs-400 100 50
heads-3 legs-11 No solution
heads-3 legs-12 0 3
heads-5 legs-10 5 0
Problem 1: Program to Flatten tuple of list.
Input: ([5, 6], [6, 7, 8, 9], [3])
Output: (5, 6, 6, 7, 8, 9, 3)
Input: ((4, 'Gfg', 10), (3, 'is', 8), (6, 'Best', 10)), ['key', 'value', 'id']
Output: [{'key': 4, 'value': 'Gfg', 'id': 10}, {'key': 3, 'value': 'is', 'id': 8}, {'key': 6, 'value': 'Best', 'id': 10}]
Input: [('Gfg', 3), ('best', 9), ('CS', 10), ('Geeks', 2)], ['Geeks', 'best', 'CS', 'Gfg']
Output: [('Geeks', 2), ('best', 9), ('CS', 10), ('Gfg', 3)]
Input: [(4, 6), (1, 2), (9, 2), (2, 1), (5, 7), (6, 4), (9, 2)]
Output: [(2, 9), (1, 2), (4, 6), (5, 7)]
Input: [(54, 2), (34, 55), (222, 23), (12, 45), (78, )], k = 2
Output: [(34, 55), (12, 45), (78,)]
Problem 2: Program to Remove None elements from Tuple.
Input: [(None, 2), (None, None), (3, 4), (12, 3), (None, )]
Output: [(None, 2), (3, 4), (12, 3)]
Problem 3: Program to Sort tuple by Total digits.
Input: [(3, 4, 6, 723), (1, 2), (12345,), (134, 234, 34)]
Output: [(1, 2), (12345,), (3, 4, 6, 723), (134, 234, 34)]
Problem 4: Program to Sort tuple by it's last element.
Input: [(1, 3), (3, 2), (2, 1)]
Output: [(2, 1), (3, 2), (1, 3)]
Input: [(4, 5, 5, 7), (1, 3, 7, 4), (19, 4, 5, 3), (1, 2)]
Output: [(19, 4, 5, 3), (4, 5, 5, 7), (1, 3, 7, 4), (1, 2)]
Input: [(6, 24, 12), (7, 9, 6), (12, 18, 21)], k = 3
Output: [(6, 24, 12), (12, 18, 21)]
Problem 1: Program for Binary Search.
Input: [2, 5, 4, 7, 8, 9, 10], n = 8
Output: Found at index 4
Problem 2: Program for Linear Search.
Input: [2, 5, 4, 7, 8, 9, 10], n = 8
Output: Found at index 4
Fortis Hospital wants to know the medical specialty visited by the maximum number of patients. Assume that the Patient id
of the patient along with the medical specialty visited by the patient is stored in a list. The details of the medical
specialties are stored in a dictionary as follows:
{ "P" : "Pediatrics", "O" : "Orthopedics", "E" : "ENT" }
Write a function to find the medical specialty visited by the maximum number of patients and return
the name of the specialty.
Note: Assume that there is always only one medical specialty which is visited by maximum number of patients.
Sample Input Expected Output
[ 101, 'P', 102, 'O', 302, 'P', 305, 'P'] Pediatrics
[ 101, 'O', 102, 'O', 302, 'P', 305, 'E', 401, 'O',656, 'O'] Orthopedics
[ 101, 'P', 102, 'E', 302, 'P', 305, 'P', 401, 'E', 656, 'O', 987, 'E'] ENT
Represent a small bilingual (English-Swedish) glossary given below as a Python dictionary
d={"merry":"god", "christmas":"jul", "and":"och", "happy":"gott", "new":"nytt","year":"ar"} and use it to translate your
Christmas wishes from English into Swedish. That is, write a python function translate() that accepts the bilingual
dictionary and a list of English words (your Christmas wish) and returns a list of equivalent Swedish words.
Input: ["merry", "christmas"]
Output: ['god', 'jul']
Problem 1: Program for Insertion Sort.
Input: [5,14,6,23,15,12,34]
Output: [5,6,12,14,15,23,34]
Problem 2: Program for Recursive Insertion Sort.
Input: [5,14,6,23,15,12,34]
Output: [5,6,12,14,15,23,34]
Problem 1: Program for Quick Sort.
Input: [5,14,6,23,15,12,34]
Output: [5,6,12,14,15,23,34]
Let we have two dictionaries.
gem_qty={“ruby” : 25,“diamond”: 30,“emrald”:15,“topaz”: 18,“sapphire”: 20}
gem_price={“ruby” : 2000,“diamond”: 4000,“emrald”:1900,“topaz”:500,“sapphire”:2500}
Input Output
diamond,ruby,topaz Total Cost: 47500
5,10,15 Gem_Qty: {'ruby': 15, 'diamond': 25, 'emrald': 15, 'topaz': 3, 'sapphire': 20}
Problem 1: Program for Bubble Sort.
Input: [64, 25, 12, 22, 11]
Output: [11, 12, 22, 25, 64]
Problem 2: Program for Selection Sort.
Input: [64, 25, 12, 22, 11]
Output: [11, 12, 22, 25, 64]
Problem 1: Program for Inverted Star Pattern.
Input: 6
Output: ******
*****
****
***
**
*
Problem 2: Program for Merge Sort.
Input: [64, 25, 12, 22, 11]
Output: [11, 12, 22, 25, 64]
Problem 1: Program to get Current Time.
Time: 19:29:53
Problem 2: Program to get Current Date and Time.
Time: 19:29:53
Date: 13-02-2021
Input : 11:28:33 PM
Output: 23:28:33
Input : 12:15:21 AM
Output: 00:15:21
Input : h1=7, m1=20, h2=9, m2=45
Output: 2 : 25
Problem 2: Convert date string to timestamp in Python.
Input : "02/04/2021"
Output: 1617301800.0
Input : 2021
Output: Monday : 52
Tuesday : 52
Wednesday : 52
Thursday : 52
Friday : 53
Saturday : 52
Sunday : 52
Input : 1617301800
Output: "02/04/2021"
Input: "ThisIsGeeksforGeeks!, 123"
Output: No. of uppercase characters = 4
No. of lowercase characters = 15
No. of numerical characters = 3
No. of special characters = 2
Input: ‘657’ let us say regular expression contain following characters - (‘78653’)
Output: Valid
Explanation: The Input string only consist of characters present in the given string.
Input: ‘7606’ let us say regular expression contain following characters - (‘102’)
Output: Invalid
Input: 100klh564abc365bg
Output: 564
Maximum numeric value among 100, 564, and 365 is 564.
Input: abchsd0sdhs
Output: 0
Input: geek55of55geeks4abc3dr2
Output: 55
Input: abcd1def2high2bnasvd3vjhd44
Output: 2
Input: BruceWayneIsBatman
Output: bruce wayne is batman
Input: GeeksForGeeks
Output: geeks for geeks
Input: abba
Output: Valid
Input: a
Output: Valid
Input: abc
Output: Invalid
Input: str = “Good bye bye world world”
Output: Good bye world
Input: str = “Hello hello world world”
Output: Hello world
Input: Geeks
Output: Yes
Input: geeksforgeeks
Output: No
Input: 123abcjw:, .@! eiw
Output: 123abcjweiw
Input: ankitrai326
Output: Accept
Input: ankirai@
Output: Discard
Input: animal
Output: Accepted
Input: zebra
Output: Not Accepted
Input:
String: "geeks for geeks makes learning fun"
Substring: "geeks"
Output: True
Input:
String: "geeks for geeks makes learning fun"
Substring: "makes"
Output: False
Input: https://www.geeksforgeeks.org/courses
Output:
Hostname: geeksforgeeks.com
Protocol: https
Input: “https://www.geeksforgeeks.org/”
Output: Yes
Input: “https:// www.geeksforgeeks.org/”
Output: No
Input: ["gfg.html", "geeks.xml", "computer.txt", "geeksforgeeks.jpg", "hey.png"], x = png
Output: hey.png
Problem 2: Check if email address valid or not.
Input: ankitrai326@gmail.com
Output: Valid Email
Input: my.ownsite@ourearth.org
Output: Valid Email
Input: ankitrai326.com
Output: Invalid Email
Problem 1: Program to check the validity of a Password.
Primary conditions for password validation :
1) Minimum 8 characters.
2) The alphabets must be between [a-z]
3) At least one alphabet should be of Upper Case [A-Z]
4) At least 1 number or digit between [0-9].
5) At least 1 character from [ _ or @ or $ ]
Input: R@m@_f0rtu9e$
Output: Valid Password
Input: Rama_fortune$
Output: Invalid Password
Explanation: Number is missing
Input: Rama#fortu9e
Output: Invalid Password
Explanation: Must consist from _ or @ or $
Conditions to be fulfilled are:
1) Minimum 9 characters and maximum 20 characters.
2) Cannot be a newline or a space
3) There should not be three or more repeating characters in a row.
4) The same string pattern(minimum of two character length) should not be repeating.
Input1: Qggf!@ghf3
Output1: Strong Password!
Input2: aaabnil1gu
Output2: Weak Password: Same character repeats three or more times in a row
Input3: Geeksforgeeks
Output3: Weak Password: Same character repeats three or more times in a row
Input4: Aasd!feasnm
Output4: Weak password: Same string pattern repetition
Input5: 772*hdf77
Output5: Weak password: Same string pattern repetition
Input6: " "
Output6: Password cannot be a newline or space!
Input: 64
Output: True(because 2^6 = 64)
Input: 32
Output: True(because 2^5 = 32)
Input: 63
Output: False
Input: 27
Output: True(because 3^3 = 27)
Input: 81
Output: True(because 3^4 = 81)
Input: 21
Output: False
Input: 16, 2
Output: True
Input: 12, 2
Output: False
Input: 81, 3
Output: True
Input: 8
Output: False
Input: 9
Output: True
Input: 100
Output: True
Problem 1: Program to find missing numbers from a list.
Input: [1,2,3,4,6,7,10]
Output: [5, 8, 9]
Input: [10,11,12,14,17]
Output: [13, 15, 16]
Input: [1,2,3,4,6,7,8]
Output: 5
Input: [10,11,12,14,15,16,17]
Output: 13
Input: [-1,0,1,2,-1,-4]
Output: [[-1, -1, 2], [-1, 0, 1]]
Note: Find the Unique Triplets in the array.
Input: [1, 0, -1, 0, -2, 2], N = 0
Output: [[-2, -1, 1, 2], [-2, 0, 0, 2], [-1, 0, 0, 1]]
Explanation: In the output list you can see that all the elements have the Sum = 0.
(-2) + (-1) + (1) + (2) = 0
Input: 48
Output: 3
For example given number is 48, the result will be 3.
Step 1: 4 + 8 = 12
Step 2: 1 + 2 = 3
Input: [5, 3, 4, 3, 4]
Output: 5
^
10 ^ 12
10: 1010
12: 1100
0110 ---> 6
Explanation: 1 ^ 0 -> 1, 0 ^ 1 -> 1, 1 ^ 1 = 0
&
10 & 12
10: 1010
12: 1100
1000 ---> 8
Explanation: 1 & 0 -> 0, 0 & 1 -> 0, 1 & 1 = 1
|
10 | 12
10: 1010
12: 1100
1110 ---> 14
Explanation: 1 | 0 -> 1, 0 | 1 -> 1, 1 | 1 = 1
10 and 12 -> 12
12 and 10 -> 10
15 and 14 -> 14
10 or 12 -> 10
12 or 10 -> 12
15 or 14 -> 15
->] The Additive Sequence is a sequence of numbers where the sum of the first two numbers
is equal to the third one.
Input: 66121830
Output: True, because 6 + 6 = 12, 6 + 12 = 18, 12 + 18 = 30
Input: 51123
Output: False
Input: 5115516
Output: True, because 511 + 5 = 516
Input: 1234
Output: 1260388352
Explanation: 1234 represented in binary as 10011010010 and returns 1260388352 which
represents in binary as 1001011001000000000000000000000.
->] Arithmetic Progression or arithmetic sequence is a sequence of numbers such that the difference
between the consecutive terms is constant.
Input: [5, 7, 9, 11]
Output: True
Input: [5, 8, 9, 11]
Output: False
Explanation: The sequence 5, 7, 9, 11, 13, 15 ... is an arithmetic progression
with common difference of 2.
- Divide the number by 16.
- Get the integer quotient for the next iteration.
- Get the remainder for the hex digit.
- Repeat the steps until the quotient is equal to 0.
Division by 16 | Quotient | Remainder | Hex |
---|---|---|---|
7562 / 16 | 472 | 10 | A |
472 / 16 | 29 | 8 | 8 |
29 / 16 | 1 | 13 | D |
1 / 16 | 0 | 1 | 1 |
Division by 16 | Quotient | Remainder | Hex |
---|---|---|---|
35631 / 16 | 2226 | 15 | F |
2226 / 16 | 139 | 2 | 2 |
139 / 16 | 8 | 11 | B |
8 / 16 | 0 | 8 | 8 |
->] Geometric Progression or geometric sequence is a sequence of numbers where each term after the first is found by
multiplying the previous one by a fixed, non-zero number called the common ratio.
Input: [2, 6, 18, 54]
Output: True
Input: [10, 5, 2.5, 1.25]
Output: False
Input: [5, 8, 9, 11]
Output: False
Explanation: The sequence 2, 6, 18, 54, ... is a geometric progression with common ratio 3.
Similarly, 10, 5, 2.5, 1.25, ... is a geometric sequence with common ratio 1/2.
Input: 13, 14
Output: 27
Input: 130, 1
Output: 23
Input: 305, 794
Output: 1
Note : The result will not be unique for every number for example 31 is a reversed form of several numbers of 13, 130, 1300 etc.
Therefore all the leading zeros will be omitted. Means 031 -> 31, 0001 -> 1
Input: 12
Output: [12, 6.0, 3.0, 10.0, 5.0, 16.0, 8.0, 4.0, 2.0, 1.0]
Info: The Collatz conjecture is a conjecture in mathematics. The conjecture is also known as the 3n + 1 conjecture.
The conjecture can be summarized as follows. Take any positive integer n. If n is even, divide it by 2 to get n / 2.
If n is odd, multiply it by 3 and add 1 to obtain 3n + 1.
Repeat the process (which has been called "Half Or Triple Plus One") indefinitely.
The conjecture is that no matter what number you start with, you will always eventually reach 1.
Input: 6
Output: True
Input: 7
Output: False
Note: Hamming numbers are numbers of the form H = 2i x 3j x 5k, Where i, j, k ≥ 0.
The sequence of Hamming numbers 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27. . .
consists of all numbers of the form 2i.3j.5k where i, j and k are non-negative integers.
Input: 24
Output: 2 3 4 5 6 8 9 10 12 15 16 18 20 24
Input: cautioned, education
Output: True
Input: cat, rat
Output: False
Input: [0, 2, 3, 4, 6, 7, 10]
Output: [2, 3, 4, 6, 7, 10, 0]
Input: [10, 0, 11, 12, 10, 14, 0, 17]
Output: [0, 11, 12, 14, 0, 17, 10, 10]
Input: 12
Output: True
Input: 13
Output: False
Info: Ugly numbers are positive numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, ...
shows the first 10 ugly numbers.
Note: 1 is typically treated as an ugly number.
Input: [4, 5, 4, 5, 2, 2, 3, 3, 2, 4, 4]
Output: 2, here 2 occurs 3 times i.e odd times.
Input: limit = 8
Output: 10
Explanation: 2 + 8 = 10
Input: limit = 400
Output: 188
Explanation: 2 + 8 + 34 + 144 = 188
Input: 4
Output: 99000099
Input: 3
Output: 906609
Input: 330
Output: 11
Explanation: The Prime Factors of 330 are 2, 3, 5 and 11. Therefore 11 is the largest prime factor of 330.
Input: limit = 200
Output: 5
Input: 10
Output: 2520
Explanation: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
Input: 20
Output: 232792560
Input: 200
Output: 401323300
Explanation:
The sum of the squares of the first twenty natural numbers is, 12+22+32+.....+202 = 404010000
The square of the sum of the first twenty natural numbers is, (1 + 2 + ... + 10)2 = 2686700
Hence, the difference between the sum of the squares of the first twenty natural numbers
and the square of the sum is 404010000 – 2686700 = 401323300
Problem 2: Program to find the nth prime number.
Input: 6
Output: 13
Explanation: 13 is the 6th Prime Number.
Input: 600
Output: 4409
Input: 500
Output: 504
Explanation: The smallest pair of amicable numbers is (220, 284). They are amicable
because the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, of which the
sum is 284; and the proper divisors of 284 are 1, 2, 4, 71 and 142, of which the sum is 220.
Input: 10000
Output: 31626
Input: 15
Output: 28
Explanation: A triangular number is a number that is the sum of all of the natural numbers up to a certain number.
For example, 10 is a triangular number because 1 + 2 + 3 + 4 = 10. The first 25 triangular
numbers are: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, and 351.
A triangular number is calculated by the equation: n(n+1)/2
The factors of the first five triangle numbers:
1: 1
3: 1, 3
6: 1, 2, 3, 6
10: 1, 2, 5, 10
15: 1, 3, 5, 15
In the above list 6 is the first triangle number to have over four divisors.
Input: 100
Output: 73920
Input: 4A3B2C1D2A
Output: AAAABBBCCDAA
Input: 1P1H1P
Output: PHP
Input: 3
Output: Index - 12, Numbers - 144
Explanation: F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F12 = 144
The 12th term, F12, is the first term to contain three digits.
Input: "kitten", "sitting"
Output: Replace: K <--> S
Replace: e <--> i
Replacement Required: 3
Explanation: The edit distance between two strings refers to the minimum number of character insertions, deletions,
and substitutions required to change one string to the other.
For example, the edit distance between "kitten" and "sitting" is three: substitute the "k" for "s",
substitute the "e" for "i", and append a "g".
Input: "medium", "median"
Output: Replace: u <--> a
Replace: m <--> n
Replacement Required: 2
Input: [10, 20, 30, 40, 50]
Output: [1200000, 600000, 400000, 300000, 240000]
Input: [1, 2, 0, 4]
Output: [0, 0, 8, 0]
Input: [('SFO', 'HKO'), ('YYZ', 'SFO'), ('YUL', 'YYZ'), ('HKO', 'ORD')], Start_string = 'YUL'
Output: ['YUL', 'YYZ', 'SFO', 'HKO', 'ORD']
Explanation: For example, given the list of flights [('SFO', 'HKO'), ('YYZ', 'SFO'), ('YUL', 'YYZ'), ('HKO', 'ORD')]
and starting airport 'YUL', you should return the list ['YUL', 'YYZ', 'SFO', 'HKO', 'ORD'].
Input: [('A', 'B'), ('A', 'C'), ('B', 'C'), ('C', 'A')], Start_string = 'A'
Output: ['A', 'C', 'A', 'B', 'C']
Input: [('SFO', 'COM'), ('COM', 'YYZ')], Start_string = 'COM'
Output: Invalid Intinerary
Input: 3
Output: 0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Input: 2
Output: 0 0
0 1
1 0
1 1
Problem: Program to Reverse a linked list.
Input: 1 -> 2 -> 3 -> 4 -> NULL
Output: 4 -> 3 -> 2 -> 1 -> NULL
Input: NULL
Output: NULL
Problem: Program for Tower of Hanoi.
Input: 2
Output: Move Disk from A to B
Move Disk from A to C
Move Disk from B to C
Input: 3
Output: Move Disk from A to C
Move Disk from A to B
Move Disk from C to B
Move Disk from A to C
Move Disk from B to A
Move Disk from B to C
Move Disk from A to C
Input: 1212112
Output: Yes
Explanation: the odd position element is 2+2+1=5
the even position element is 1+1+1+2=5
the difference is 5-5=0.so print yes.
Input: 12345
Output: No
Explanation: the odd position element is 1+3+5=9
the even position element is 2+4=6
the difference is 9-6=3 not equal to zero. So print no.
Problem: Program to Print Matrix in Z form.
Input: [[4, 5, 6, 8],
[1, 2, 3, 1],
[7, 8, 9, 4],
[1, 8, 7, 5]]
Output: 4 5 6 8
3
8
1 8 7 5
Input: [[4, 5, 6, 8, 5],
[1, 2, 3, 1, 4],
[7, 8, 9, 4, 7],
[1, 8, 7, 5, 2],
[7, 9, 5, 6, 9],
[9, 4, 5, 6, 6]]
Output: 4 5 6 8 5
1
9
8
7
9 4 5 6 6
Input: L_list.Insert_At_Beginning(1)
L_list.Insert_At_Beginning(2)
L_list.Insert_At_Beginning(3)
L_list.Insert_At_End(4)
L_list.Insert_At_End(5)
L_list.Insert_At_End(6)
L_list.Insert_After(L_list.head.next, 10)
Output: 3 -> 2 -> 10 -> 1 -> 4 -> 5 -> 6 -> None
Input: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> None, key = 4
Output: 1 -> 2 -> 3 -> 5 -> 6 -> None
Problem: Program to Sort a Linked List.
Input: 8 -> 5 -> 10 -> 7 -> 6 -> 11 -> 9 -> None
Output: 5 -> 6 -> 7 -> 8 -> 9 -> 10 -> 11 -> None
Input: 8 -> 5 -> 10 -> 7 -> 6 -> 11 -> 9 -> None, key1 = 8, key2 = 5
Output: 5 -> 8 -> 10 -> 7 -> 6 -> 11 -> 9 -> None
Input: L1 = 5 -> 8 -> 10, L2 = 7 -> 9 -> 11 ->12
Output: 5 -> 7 -> 8 -> 9 -> 10 -> 11 -> 12 -> None
Input: 5 -> 8 -> 10 -> 7 -> 9 -> 11 -> 12 -> None
Output: 5 -> 7 -> 8 -> 9 -> 10 -> 11 -> 12 -> None
Input: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> None, size = 2
Output: 2 -> 1 -> 4 -> 3 -> 6 -> 5 -> 7 -> None
Input: 8 -> 5 -> 10 -> 7 -> 6 -> 11 -> 9 -> 5
Output: Loop Found, 8 -> 5 -> 10 -> 7 -> 6 -> 11 -> 9 -> None
Input: 7 -> 5 -> 9 -> 4 -> 6 -> None // i.e. 64957, 8 -> 4 -> None // i.e. 48
Output: 5 -> 0 -> 0 -> 5 -> 6 -> None // i.e. 65005
Problem: Program to Rotate a Linked List.
Input: 9 -> 11 -> 6 -> 7 -> 10 -> 5 -> 8 -> None, key = 4
Output: 10 -> 5 -> 8 -> 9 -> 11 -> 6 -> 7 -> None
Input: L_list.Add_to_Empty(6)
L_list.Add_to_Begin(4)
L_list.Add_to_Begin(2)
L_list.Add_to_End(8)
L_list.Add_to_End(12)
L_list.Add_After(10, 8)
Output: 2 -> 4 -> 6 -> 8 -> 10 -> 12 -> 2
Input: 10 -> 12 -> 8 -> 2 -> 4 -> 6
Output: First Split Linked List: 10 -> 12 -> 8
Second Split Linked List: 2 -> 4 -> 6
Input: [12, 56, 2, 11, 1, 90]
Output: 1 -> 2 -> 11 -> 12 -> 56 -> 90 -> 1
Input: L_list.Add_at_front(5)
L_list.Add_at_front(7)
L_list.Add_at_front(9)
L_list.Add_at_front(8)
L_list.Add_End(2)
L_list.Add_End(6)
L_list.Add_After(L_list.head.next, 1)
Output: Traversal in Forward Direction: 8 -> 9 -> 1 -> 7 -> 5 -> 2 -> 6
Traversal in Reverse Direction: 6 -> 2 -> 5 -> 7 -> 1 -> 9 -> 8
Problem 1: Program for Binary Insertion Sort.
Input: 12, 56, 2, 11, 1, 90
Output: 1, 2, 11, 12, 56, 90
Problem 2: Program for Linear Insertion Sort.
Input: 12, 56, 2, 11, 1, 90
Output: 1, 2, 11, 12, 56, 90
Input: 8 -> 9 -> 1 -> 7 -> 5 -> 2 -> 6, Node to be Deleted: 1, 7, 6
Output: 8 -> 9 -> 5 -> 2
Input: 8 -> 9 -> 1 -> 7 -> 5 -> 2 -> 6
Output: 6 -> 2 -> 5 -> 7 -> 1 -> 9 -> 8
Input: 8 -> 9 -> 1 -> 7 -> 5 -> 2 -> 6
Output: 6 -> 2 -> 5 -> 7 -> 1 -> 9 -> 8
Input: "a+b*(c^d-e)^(f+g*h)-i"
Output: abcd^e-fgh*+^*+i-
Input: "231*+9-"
Output: -4
Input: [()]{}{[()()]()}
Output: Balanced
Input: [(])
Output: Not Balanced
Problem: The Stock Span Problem.
Input: [100, 80, 60, 70, 60, 75, 85]
Output: [1, 1, 1, 2, 1, 4, 6]