VICKY.HIMANSHU18
BAN USERHere is my solution for this problem:
1.) Every node or server will maintain the two local copy(current local changed version) and Shadow copy(which will represent the copy it received from the other server last time).
2.) There will be one operation stack which will represent all the operation being done on the node of the list until it received ack back from the network for the changes it send last time.
3.) When the node get the ack, it will remove all the operation in the stack uptil that version.
4.) If any time while merging the changes with local copy server finds both of the version whatever its storing and whatever it received are out of sync from one than one version. It will discard all the changes and take the backup from the shadow copy and again calculate the diff and send it across the network.
This is the same solution which is being used by all online shared document editors and really scales well.
We can apply BFS here. We can start from bbb and then for every iteration we will have four different strings like: bbb+'a', 'a'+bbb, 'b'+bbb, bbb+'b'. As last two strings are same we will only add one in the queue. Now we can keep on iterating until our N becomes 0.
- VICKY.HIMANSHU18 September 04, 2019This problem is similar problem like step numbers.