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

Maximal Network Rank Solution

Microsoft Online Assessment 2021 Questions and Solution

Microsoft Online Assessment Maximal Network Rank Solution There is an infrastructure of n cities with some number of roads connecting these cities. Each roads[i] = [ai, bi] indicates that there is a bidirectional road between cities ai and bi. The network rank of two different cities is defined as the total number of directly connected roads to either city. If a road is directly connected to both cities, it is only counted once. … Read more

Jumping Around Codeforces Solution

Jumping Around Codeforces Solution There is an infinite pond that can be represented with a number line. There are nn rocks in the pond, numbered from 11 to nn. The ii-th rock is located at an integer coordinate aiai. The coordinates of the rocks are pairwise distinct. The rocks are numbered in the increasing order of the coordinate, so a1<a2<⋯<ana1<a2<⋯<an. A robot frog … Read more

Maximum Cost Deletion Codeforces Solution

Maximum Cost Deletion Codeforces Solution You are given a string ss of length nn consisting only of the characters 0 and 1. You perform the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from the string and glue the remaining two parts together (any of them can be empty) in the same order. For example, if you erase … Read more

Exciting Bets Codeforces Solution

Exciting Bets Solution Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet aa dollars and Ronnie has bet bb dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b)gcd(a,b), where gcd(x,y)gcd(x,y) denotes the greatest common divisor (GCD) of integers xx and yy. To make … Read more

The Final Pursuit Codeforces Solution

The Final Pursuit Solution Finally, you have defeated Razor and now, you are the Most Wanted street racer. Sergeant Cross has sent the full police force after you in a deadly pursuit. Fortunately, you have found a hiding spot but you fear that Cross and his force will eventually find you. To increase your chances … Read more

RPD and Rap Sheet (Easy Version) Codeforces Solution

RPD and Rap Sheet (Easy Version) Solution This is the easy version of the problem. The only difference is that here k=2k=2. You can make hacks only if both the versions of the problem are solved. Every decimal number has a base kk equivalent. The individual digits of a base kk number are called kk-its. Let’s define the kk-itwise XOR of two kk-its aa and bb as (a+b)modk(a+b)modk. … Read more

error: Content is protected !!
Please Click on 1 or 2 Ads to help us run this site.