Week 12: Programming Assignment 1 [Due on 2025-04-17, 23:59 IST]
Given a sorted list nums in non-decreasing order, where every element appears twice except for one unique element, find and return the single number. Example 1: Input nums = [1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6] Output 4 Example 2 : Input nums = [1, 1, 3, 5, 5] Output 3 Constraints: n==len(nums) 1<=n<=104
Week 12: Programming Assignment 2 [Due on 2025-04-17, 23:59 IST ]
You are given a string s consisting of only lowercase English letters. Your task is to return a list of unique characters from the string, sorted in descending order based on their frequency of occurrence. If two or more characters have the same frequency, they should be sorted in alphabetical order. Input: A string s The string consists of only lowercase English characters ('a' to 'z'). Output: A list of unique characters sorted by frequency (highest to lowest). If characters have the same frequency, they should appear in alphabetical order. Example 1: Input: s = "tree" Output: ['e', 'r', 't'] Example 2 : Input: s = "bbccddaaa" Output: ['a', 'b', 'c', 'd'] Explanation: The frequency of each character: 'a' → 3 'b' → 2 'c' → 2 'd' → 2 Since 'b', 'c', and 'd' have the same frequency, they are sorted alphabetically.
Week 12: Programming Assignment 3 [Due on 2025-04-17, 23:59 IST ]
Write a Python function subsequence(l1,l2) that takes two sorted lists as arguments and returns True if the the first list is a subsequence of the second list, and returns False otherwise. A subsequence of a list is obtained by dropping some values. Thus, [2,3,4] and [2,2,5] are subsequences of [2,2,3,4,5], but [2,4,4] and [2,4,3] are not. For Example : Input : subsequence([2,2,5],[2,2,3,4,5]) Output : True
Week 11: Programming Assignment 1 Due on 2025-04-10, 23:59 IST
You are given a list of n distinct integers in the range [0, n] (inclusive). This means exactly one number from this range is missing. Your task is to determine and return the missing number. Input: A list nums containing n distinct integers from 0 to n. Output: The missing integer in the range [0, n] Examples: Input: nums = [0, 2, 3, 1, 4] Output: 5 The list contains {0, 1, 2, 3, 4}, so 5 is missing. Input: nums = [0, 1, 2, 4, 5, 6] Output: 3 The list contains {0, 1, 2, 4, 5, 6}, so 3 is missing.
Week 11: Programming Assignment 2 Due on 2025-04-10, 23:59 IST
Given a list of integers nums and an integer k, write a Python function to check whether there exists a subsequence (a non-contiguous subset of the list) such that the sum of its elements equals k. Return True if such a subsequence exists, otherwise False. Example 1 : Input: nums = [1, 2, 3, 4, 5] k = 8 Output: True Example 2 : Input: nums = [4, 3, 9, 2] k = 10 Output: False Constraints : 1<=len(nums)<=20 1<=nums[i]<=100 1<=k<=2000
Week 11: Programming Assignment 3 Due on 2025-04-10, 23:59 IST
Given a string s representing a large integer, return the largest-valued odd integer (as a string) that is a substring of s. Note: The result should not contain any leading zeros. The input string s may contain leading zeros. Constraints : 1 <= s.length <= 10^3 '0' <= s[i] <= '9' Examples: Example 1: Input: s = "5347" Output: "5347" Explanation: All possible odd numbers: {5, 3, 53, 347, 5347} The largest odd number is "5347". Example 2: Input: s = "0214638" Output: "21463" Explanation: Valid odd numbers: {1, 3, 21, 63, 463, 1463, 21463} Leading zeros cannot be included. The largest odd number is "21463". Example 3: Input: s = "0032579" Output: "32579"