Python algorithm problem

Asked 2 years ago, Updated 2 years ago, 39 views

https://programmers.co.kr/tryouts/850/intro You can see the problem if you go to the address here. It's this kind of problem. I'm going to find the biggest pattern that matches this problem from the very beginning, and then I'm going to use that pattern and I'm going to do this again and I'm going to cut all the characters. That's the logic. But if you squeeze it like this, there's a problem. There are times when you can't write all the letters at all. Like this, there are cases where it is not the minimum value at all. I have no idea how to solve this. I've been thinking about this for days and days, and I can't even sleep. I can't find the answer. How do I solve this? I'd really appreciate your help.

algorithm python

2022-09-21 22:59

2 Answers

This is a very difficult problem.

I'd like you to study something called dynamic programming.


2022-09-21 22:59

If M(n) is the minimum number of characters required when constructed using the characters of strs from the nth to the last position of the string t, M(n) is the string containing the string from the nth to the nth + kth position, then M(n) is the smallest of 1 + M(n + k + 1) and (k is 0 to 4). If the minimum is infinite, let's just say there's no possible way.


2022-09-21 22:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.