Microsoft OA Longest Substring Without Two Contiguous Occurrences of Letter

Microsoft Online Assessment 2021 Questions and Solution

Microsoft Online Assessment Longest Substring Without Two Contiguous Occurrences of Letter Longest Substring Without Two Contiguous Occurrences of Letter Given a string str containing only a and b, find the longest substring of str such that str does not contain more than two contiguous occurrences of a and b. Also See: Microsoft Online Assessment Questions and Solution Example 1: Input: aabbaaaaabb Output: aabbaa Example 2: Input: aabbaabbaabbaaa Output: aabbaabbaabbaa Solution Program … Read more

Microsoft OA Lexicographically Smallest String

Microsoft Online Assessment 2021 Questions and Solution

Microsoft Online Assessment Lexicographically Smallest String Given a string str, the task is to find the lexicographically smallest string that can be formed by removing at most one character from the given string. Also See: Microsoft Online Assessment Questions and Solution Example 1: Input: abczd Output: abcd Example 2: Input: abcda Output: abca Explanation: One can remove d to get abca which is … Read more

Minimum Adjacent Swaps to Make Palindrome Solution

Microsoft Online Assessment 2021 Questions and Solution

Microsoft Online Assessment Minimum Adjacent Swaps to Make Palindrome Given a string, what is the minimum number of adjacent swaps required to convert a string into a palindrome. If not possible, return -1. Also See: Microsoft Online Assessment Questions and Solution Example 1: Explanation: swap m with a => maamd swap m with d => maadm swap a with d => madam Example 2: Example 3: Example 4: Solution Program Python: Program Java: … Read more

Microsoft OA Day of week that is K days later Solution

Microsoft Online Assessment 2021 Questions and Solution

Microsoft Online Assessment Day of week that is K days later Given current day as day of the week and an integer K, the task is to find the day of the week after K days. Also See: Microsoft Online Assessment Questions and Solution Example 1: Input: day = “Monday” K = 3 Output: Thursday Example 2: Input: day = “Tuesday” K = 101 Output: Friday Solution Program Python: Program … Read more

Min Deletions To Obtain String in Right Format

Microsoft Online Assessment 2021 Questions and Solution

Microsoft Online Assessment Min Deletions To Obtain String in Right Format You are given a string s consisting only of characters ‘a’ and ‘b’​​​​. You can delete any number of characters in s to make s balanced. s is balanced if there is no pair of indices (i,j) such that i < j and s[i] = ‘b’ and s[j]= ‘a’. Return the minimum number of deletions needed to make s balanced. Also See: Microsoft Online Assessment Questions and Solution Example … Read more

Please Click on 1 or 2 Ads to help us run this site.
+