Today they gave us in the LCPC training this exercise:
We define a stable string:
1- the string is {}
2- if S is a stable string then {S} is also stable
3- if S and T are stable strings then TS is also stable
examples of stable strings:
{}, {}{}, {{}{}}...
examples of unstable strings:
}{, }{{{...
Given a string of size N 2<=N<=2000 (N is given even)
find the least operations to do on a string to make it stable:
the only operation allowed is to change { to } or vice-versa
Examples:
{{ result: 1
}{ result: 2
{{{} result:1
I will post my solution soon
We define a stable string:
1- the string is {}
2- if S is a stable string then {S} is also stable
3- if S and T are stable strings then TS is also stable
examples of stable strings:
{}, {}{}, {{}{}}...
examples of unstable strings:
}{, }{{{...
Given a string of size N 2<=N<=2000 (N is given even)
find the least operations to do on a string to make it stable:
the only operation allowed is to change { to } or vice-versa
Examples:
{{ result: 1
}{ result: 2
{{{} result:1
I will post my solution soon