Python3 | Monotonic Stack | Greedy
\nclass Solution:\n    def maxNumber(self, nums1: List[int], nums2: List[int], k: int) -> List[int]:\n        \n        def find_k_max_number_in_an_array(nums, 
```\nclass Solution:\n    def maxNumber(self, nums1: List[int], nums2: List[int], k: int) -> List[int]:\n        \n        def find_k_max_number_in_an_array(nums, k):\n            drop_possible = len(nums) - k\n            n = len(nums)\n            stack = []\n            for i, val in enumerate(nums):\n                while stack and drop_possible and stack[-1] < val:\n                    drop_possible -= 1\n                    stack.pop()\n                \n                stack.append(val)\n            \n            return stack[:k]\n                \n        \n        def merge_two_array(arr1, arr2):\n            #print(arr1, arr2)\n            return [max(arr1, arr2).pop(0) for _ in arr1 + arr2]\n\n        def compare_two_array(arr1, arr2):\n            """\n            determine whether arr1 is greater than arr2\n            """\n            if not arr2:\n                return True\n            i = j = 0\n            n = len(arr1)\n            while i < n and j < n:\n                if arr1[i] > arr2[j]:\n                    return True\n                elif arr1[i] < arr2[j]:\n                    return False\n                i += 1\n                j += 1\n            \n            return True\n        \n        ans = 0\n        for i in range(k + 1):\n            p = k - i\n            \n            if i > len(nums1) or p > len(nums2):\n                continue\n            \n            # get this two array by solving function find_k_max_number_in_an_array\n            # using similar concept of 402. Remove K Digits\n            first_arr = find_k_max_number_in_an_array(nums1, i)\n            second_arr = find_k_max_number_in_an_array(nums2, p)\n            \n            # merge two array with everytime taking lexicographily larger list\n            # https://leetcode.com/problems/create-maximum-number/discuss/77286/Short-Python-Ruby-C%2B%2B\n            # see explanation\n            curr_arr = merge_two_array(first_arr, second_arr)\n            #print(curr_arr)\n            \n            # can be directly use python max function\n            if compare_two_array(curr_arr, ans):\n                ans = curr_arr\n            # ans = max(ans, curr_arr) if ans else curr_arr\n            \n            #print(ans)\n        \n        return ans\n\n```
['Monotonic Stack', 'Python', 'Python3']