All Posts
Leetcode 1824: Minimum Sideway Jumps
A frog is traveling on a 3-lane road, starting at point 0 on lane 2. The frog wants to reach point n, but there may be obstacles at various points on the road. The frog can either move forward on the same lane or jump to another lane if the current lane is blocked. The goal is to find the minimum number of side jumps the frog needs to take to reach point n while avoiding obstacles.
Leetcode 1871: Jump Game VII
You are given a binary string s
and two integers minJump
and maxJump
. Initially, you are at index 0
of the string s
, which is guaranteed to be ‘0’. You can move from index i
to index j
if: i + minJump <= j <= min(i + maxJump, s.length - 1), and s[j] == ‘0’. Return true
if it’s possible to reach the last index of the string (s.length - 1
), or false
otherwise.
Leetcode 1888: Minimum Number of Flips to Make the Binary String Alternating
You are given a binary string s consisting of ‘0’s and ‘1’s. You can perform two operations on the string:
- Type-1: Move the first character of the string to the end.
- Type-2: Flip the value of any character in the string (‘0’ becomes ‘1’ and ‘1’ becomes ‘0’). The goal is to make the string alternating, i.e., no two adjacent characters should be the same. You need to find the minimum number of type-2 operations required to make the string alternating.