Given 2 lists, for a given index, 2nd list element is always larger than first, and if not, we rearrange it.
Input : test_list1 = [36, 38, 40, 132], test_list2 = [35, 37, 39, 41, 133]
Output : [37, 39, 41, 133]
Explanation : Each element in result list is greater than its index counterpart of 1st list. (Eg. 37 > 36)
Input : test_list1 = [2, 6], test_list2 = [5, 3, 8]
Output : [5, 8]
Explanation : Here 5 > 2 and 8 > 6.
Method : Using loop
This is brute way to tackle this problem. In this, we try to get best suitable next higher element after the whole list traversal and perform the necessary rearrangement.
The original list 1 is : [14, 16, 18, 110] The original list 2 is : [13, 15, 17, 19, 111] List 2 after conversion : [15, 17, 19, 111]
- Python | Get the Index of first element greater than K
- Python | Replace elements in second list with index of same element in first list
- Python - Group first elements by second elements in Tuple list
- Python | Largest, Smallest, Second Largest, Second Smallest in a List
- How to rearrange columns of a 2D NumPy array using given index positions?
- Minimum value of K such that sum of cubes of first K natural number is greater than equal to N
- Python - Filter the List of String whose index in second List contaons the given Substring
- Python - Storing Elements Greater than K as Dictionary
- Python - Extract elements with Frequency greater than K
- Python - Replace Elements greater than K
- Python program to print Rows where all its Elements' frequency is greater than K
- Python | Subtract two list elements if element in first list is greater
- Sort the values of first list using second list in Python
- Python - Find first element by second in tuple List
- Python - Combine two dictionaries having key of the first dictionary and value of the second dictionary
- Python | Rearrange Positive and Negative Elements
- Python - Test if common values are greater than K
- Python | Check if all the values in a list that are greater than a given value
- Python | Number of values greater than K in list
- Python | Find smallest element greater than K