I want to have a python version solution to this question, Thank you so much! And please show some explanations with tim

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

I want to have a python version solution to this question, Thank you so much! And please show some explanations with tim

Post by answerhappygod »

I want to have a python versionsolution to this question, Thank you so much! And please show someexplanations with time complexity and space complexity.
* Given a jumbled collection of segments, each of which isrepresented as a Pair(startPoint, endPoint), this function sortsthe segments to make a continuous path.** A few assumptions you can make:* 1. Each particular segment goes in one direction only, i.e.: ifyou see (1, 2), you will not see (2, 1).* 2. Each starting point only have one way to the end point, i.e.:if you see (6, 5), you will not see (6, 10), (6, 3), etc.* For example, if you've passed a list containing thefollowing int arrays:
[(4, 5), (9, 4), (5, 1), (11, 9)]
* Then your implementation should sort it such:
[(11, 9), (9, 4), (4, 5), (5, 1)]
@param segments collection of segments, each representedby a Pair(startPoint, endPoint). @return The sorted segments such that they form a continuouspath. @throws Exception if there is no way to create one continuouspath from
all the segments passed into this function. Feel free to changethe Exception type as you think appropriate.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply