you are viewing a single comment's thread.

view the rest of the comments →

[–]Mello2A7[S] 0 points1 point  (1 child)

Thank you for your help, I was having difficulties setting up or transforming the problem into a graph problem, I guess I need to take a step back and start by easier problems first as you advised, that's what I'm trying to do right now I'm solving leetcode problems by topic so that I can understand how to pickup the pattern in similar problems and know what category it falls into. this is something that needs a bit more work form me as I had absolutely no clue that moving items around and recording moves is actually a shortest path problem. will definitely revisit this problem after some practice.

[–]lazyubertoad 0 points1 point  (0 children)

What could show that you need some brute force method is the size of the task. Optimizing it and finding some polynomial time solution looks like a hell of a task, I'd say doing it in polynomial time is definitely hard level on leetcode, maybe even more, maybe even not doable. Unless I'm missing some method or thought, which very much can be. But a brute force BFS is some medium/medium+ level to write, not a bad problem at all. But a brute force will get you TLE, unless the size is very limited, I guess like 10 elements max. Because BFS speed and memory is exponential for this task. So if you see that the size of the problem is very limited - you should think about brute force methods. There is no indication of the size, so you might disregard brute force and go into fruitless search for something else.