You are given two strings
sandtof equal lengthn. You can perform the following operation on the strings:
- Remove a suffix of
sof lengthlwhere0 < l < nand append it at the start ofs.
For example, lets = 'abcd'then in one operation you can remove the suffix'cd'and append it in front ofsmakings = 'cdab'.You are also given an integer
k. Return the number of ways in whichscan be transformed intotin exactlykoperations.Since the answer can be large, return it modulo
109 + 7.
2850. Minimum Moves to Spread Stones Over Grid
You are given a 0-indexed 2D integer matrix
gridof size3 * 3, representing the number of stones in each cell. The grid contains exactly9stones, and there can be multiple stones in a single cell.In one move, you can move a single stone from its current cell to any other cell if the two cells share a side.
Return the minimum number of moves required to place one stone in each cell.