+ 1

coding:Bulb chain{lets Improve code } share your way of solving this problem

A light store owner has several bulb chains of different types which consist of bulbs of different colors in different order. In addition to that, he has large collection of bulbs of each color. A bulb chain is identified by the color sequence of its bulbs. He wants to transform one type of bulb chain into another type of bulb chain by either by: Adding a bulb at some location. Removing a bulb from a location. Replacing a bulb with another bulb of different color. Given two color sequences of two different bulb chains, Find the minimum no. of operations required to do this transformation. (Assume each color can be represented by a character and hence, color sequence of a bulb chain can be represented as sequence of characters or a string.) Formula/Method: Let length of string A be m and length of string B be n. we can represent these strings as A[1 m] and B[1 n]. Let transform(X,Y) be the minimum number of operations to transform string X into string Y, then Output = transform (A[1 .m], B[1 .n]) = 1+min { transform (A[1 .m-1], B[1 ..n]), transform (A[1 .m], B[1 ..n-1]), transform (A[1 .m-1], B[1 ..n-1]) } Input Format First line of input contain string A. Second line of input contain string B. Constraints 1<= Size of A, B <= 10000 Output Format You need to print the minimum no. of operations (integer) required to transform first bulb chain into the second. Sample TestCase 1 Input asdfgh sdfgh Output 1 version1: https://code.sololearn.com/cG26Q3fHZsKw

9th Sep 2019, 4:20 PM
Sgk101
Sgk101 - avatar
1 ответ
26th Sep 2019, 2:56 PM
Felix Schültz
Felix Schültz - avatar