Hard Level practice questions in Python

WAP stands for Write A Program

  1. Given a list storing the names of employees as names = [‘Aanchal Sharma’, ‘Shubham Chhipa, ‘Mohit Rawat’, ‘Salman Khan’, ‘Ishani Janveja’]
       Given a list storing the dob of the employees as dob = [’24/03/1999′, ’19/08/1997′, ’07/07/1990′, ’26/11/2000′, ’14/10/1993′]
       Create a 3rd list storing their suggested passwords as per the following format:
    Input: name = Aanchal Sharma
                   dob = 24/03/1999
    Output: pass = AS#03@24
    Logic: Initials#MM@DD
  2. Create a list storing the number of vowels in the textual representation in the range of 0 to 9 in the following format,
    [(0, 2), (1, 2), (2, 1)……]
    Logic: 0 can be written as zero. zero has 2 vowels.
  3. Given a sentence containing n words/strings. Remove all duplicates words/strings which are similar to each others.
        Examples:  
    Input : Bye Bye bro
    Output : Bye bro
    ——-
    Input : Python is great and Java is also great
    Output : is also Java Python and great
     
  4. Write a Python program to count the number of elements in a list within a specified range.
    Input: l = [2, 16, 9, 10, 15, 8, 11]
    Input Range:
       Start: 9
       End:   13
    Output:3
     
  5. You are given a list of integers nums and an integer k. Write a function max_subarray_sum that finds the maximum sum of any continuous subarray of length k in nums and returns the corresponding array.
       Example Input:
        nums = [2, 1, 5, 1, 3, 2]
        k = 3
       Function Call:
    max_subarray_sum(nums, k)
       Output: 
      array = [5, 1, 3] 
       Explanation: The subarray [5, 1, 3] has the maximum sum among all contiguous subarrays of length 3 in nums.
    Hint: You can solve this problem using the sliding window technique, where you maintain a sliding window of length k and slide it over the input list nums while keeping track of the maximum sum seen so far.