Character flipping programming interview problem
Programming interview question from the Daily Coding Problem email list. I have it as #1602, but other folks have it as #331 from 2020. I guess I missed it back then.
Daily Coding Problem: Problem #1602 [Medium]
This problem was asked by LinkedIn.
You are given a string consisting of the letters x
and y
,
such as xyxxxyxyy
.
In addition,
you have an operation called flip
,
which changes a single x
to y
or vice versa.
Determine how many times you would need to apply this operation to ensure
that all x
’s come before all y
’s.
In the preceding example,
it suffices to flip the second and sixth characters,
so you should return 2.
Repo for code.