2. Adjusting To The Market At Box, We Make Sure We Have A Well-planned Upcoming Quarter Of Work With Many Improvements For Our Customers And Users. We're Prioritizing Our Work As A Linked List With The Head Of The List Having The Highest Priority. However

匿名用户 最后更新于 2021-12-01 19:36 计算机类Computing

Please help in Python or Java.

2. Adjusting to the Market At Box, we make sure we have a well-planned upcoming quarter of work with many improvements for our customers and users. We're prioritizing our work as a linked list with the head of the list having the highest priority. However, sometimes the market changes quickly and we aim to adapt to the new requirements. This means, we have to adjust our plan for the next quarter by replacing certain work in our list. Consider two 1-Indexed linked lists, listi (planned work items for the upcoming quarter) and list2 (new items to replace deprioritized work), and two integers, a and b(start and end of work items to be replaced). Merge the two lists by removing the ath through bth nodes in list1 and inserting list2 in their place. In other words: - listin • listinitial = list 11 - • list2 = list21 + list22 - list1 merged = list 11 - listin listla list lb - fist2m listla-1 - list21 Vist2m + list1b+7 - Example a = 2 (start node index) b = 3 (end node index) list 1 = 1-2-3-4-5 list 2 = 6-7-8-9 e e Ef v EU 60OCOU e P
í 1, ou un coche 1 nm 5 to IPON oos n rocool mi }, 2 a a Function Description Complete the function mergelnBetween in the editor below. angelinBeta
Function Description Complete the function mergel Berween in the editor below. mergeln Between has the following parameters Vist1: reference to the head of a linked list of wintegers list2: reference to the head of a linked list of tegers int as the start node index for the replaced segment int by the end node index for the replaced segment Returns reference to a singlyLinkedListNode. the head of listy after merging as described Constraints • snms 105 • 1 sa sbsn • 1 s list10) s 10%, where I sisn) • 1 s list2[0 < 10° where I sism) input Format for Custom Testing Input from stdin will be processed as follows and passed to the function The first line contains an integer n, the number of elements in Visa Each of the next n lines contains an integer list 10. The next line contains an integer m, the number of elements in list2 Each of the next mlines contains an integer listel The next line contains an Integer a The next line contains an integer b. Sample Case o Sample input o STDIN Function 6 → length of listi n = 6 Tisti data - 46 1
The next line contains an Integer m, the number of elements in list2. Each of the next mlines contains an Integer list2[1]. The next line contains an integer a. The next line contains an Integer b. Sample Case 0 Sample Input o STDIN Function 6 length of listi n = 6 listi data = 1 + 4 + 6 = 3 + 2 = 7 1 4 6 3 2 7 7 5 6 length of list2 m = 7 list2 data = 5 + 6 + 4 → 3 8 → 2 + 1 4 3 12 1 a = 2 + b = 4 Sample Output o 1 5 6 4 3 8 2 1 2 7 Explanation o
def mergeInBetween (listi, list2, a, b): # Write your code here if not listl or not list2: return Listi or List2 if listi. data < list2.data: listi.next = (at self.mergeInBetween(listi,ne return listi else: List2.next = (b + self.mergeInBetween(listi, return list2 name main Test Results Custom Input Compiled successfully. Run all test cases Error (stdern) Traceback (most recent call last): File "Solution.py", line 93 in result = mergeInBetween(listi.head, List2.head, a, b) File "solution.py", line 64, in mergeInBetween listi.next =(a+ self.mergeInBetween(listi.next list2) NameError: name self is not defined Input (stdin) 6 1 4.

已邀请: