Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
2,647 views

Bonus : Best Image2Pdf feature is here : https://www.desiqna.in/image2pdf/

All past online assesments of Microsoft  can be found using the tag "microsoft_oa" in the search bar.

Here is the link : https://www.desiqna.in/tag/microsoft_oa

 

in Online Assessments by Expert (4,460 points)
edited by | 2,647 views

1 Answer

0 like 0 dislike

Microsoft Online Assessment (OA) - Min Deletions To Obtain String in Right Format

Given a string with only characters X and Y. Find the minimum number of characters to remove from the string such that there is no interleaving of character X and Y and all the Xs appear before any Y.

Example 1:

Input:YXXXYXY

Output: 2

Explanation:

We can obtain XXXYY by:

  • Delete first Y -> XXXYXY
  • Delete last occurrence pf X -> XXXYY

Example 2:

Input:YYXYXX

Output: 3

Explanation:

We can remove all occurrence of X or Y:

Example 3:

Input:XXYYYY

Output: 0

Explanation:

String matches the format required.

by Expert (4,460 points)