Solve Leetcode Problems and Get Offers From Your Dream Companies

Nil Madhab
LeetCode Simplified
3 min readJan 29, 2021

--

Weekly Contest 225: Change Minimum Characters to Satisfy One of Three Conditions

Here I will solve problems from Leetcode contests. Today we will do the Change Minimum Characters to Satisfy One of Three Conditions problem Weekly Contest 225.

Motivation to learn algorithms

Problem Statement

You are given two strings a and b that consist of lowercase letters. In one operation, you can change any character in a or b to any lowercase letter.

Your goal is to satisfy one of the following three conditions:

  • Every letter in a is strictly less than every letter in b in the alphabet.
  • Every letter in b is strictly less than every letter in a in the alphabet.
  • Both a and b consist of only one distinct letter.

Return the minimum number of operations needed to achieve your goal.

--

--

Nil Madhab
LeetCode Simplified

Developer @Booking.com | ex: Samsung, OYO | IIT Kharagpur | Entrepreneur, founder of simplecoding.dev | JOIN Medium, https://nilmadhab.medium.com/membership