Find the minimum length word from a given dictionary words, which has all the letters from the string licensePlate.  Such a word is said to complete the given string licensePlate

Here, for letters we ignore case.  For example, "P" on the licensePlate still matches "p" on the word.

It is guaranteed an answer exists.  If there are multiple answers, return the one that occurs first in the array.

The license plate might have the same letter occurring multiple times.  For example, given a licensePlate of "PP", the word "pair" does not complete the licensePlate, but the word "supper" does.


Example 1:

Input: licensePlate = "1s3 PSt", words = ["step", "steps", "stripe", "stepple"]
Output: "steps"
Explanation: The smallest length word that contains the letters "S", "P", "S", and "T".
Note that the answer is not "step", because the letter "s" must occur in the word twice.
Also note that we ignored case for the purposes of comparing whether a letter exists in the word.



Example 2:

Input: licensePlate = "1s3 456", words = ["looks", "pest", "stew", "show"]
Output: "pest"
Explanation: There are 3 smallest length words that contains the letters "s".
We return the one that occurred first.



Note:

licensePlate will be a string with length in range [1, 7].
licensePlate will contain digits, spaces, or letters (uppercase or lowercase).
words will have a length in the range [10, 1000].
Every words[i] will consist of lowercase letters, and have length in range [1, 15].

Difficulty: MEDIUM_HARD
Tags: String algorithms

Data structures
Skill types: Data structures

Starter code:
class Solution:
    def shortestCompletingWord(self, licensePlate: str, words: List[str]) -> str:
        

Solutions:
class Solution:

	def dominantIndex(self, nums):
		if len(nums) <= 1:
			return 0
		m = max(nums)
		ind = nums.index(m)
		del nums[ind]
		m_2 = max(nums)
		return ind if m >= 2 * m_2 else -1


class Solution:

	def dominantIndex(self, nums):
		max_num = 0
		s_max = 0
		max_num_index = 0
		if len(nums) != 1:
			for i in range(len(nums)):
				if nums[i] > max_num:
					s_max = max_num
					s_max_index = max_num_index
					max_num = nums[i]
					max_num_index = i
				elif nums[i] > s_max:
					s_max = nums[i]
			if max_num >= 2 * s_max:
				return max_num_index
			else:
				return -1
		else:
			return 0


class Solution:

	def dominantIndex(self, nums):
		if len(nums) == 1:
			return 0
		maxval = nums[0]
		maxindex = 0
		secVal = None
		for (i, e) in enumerate(nums):
			if i == 0:
				continue
			if e > maxval:
				(secVal, maxval) = (maxval, e)
				maxindex = i
			elif secVal is None:
				secVal = e
			elif e > secVal:
				secVal = e
		if secVal * 2 <= maxval:
			return maxindex
		return -1


class Solution:

	def dominantIndex(self, nums):
		if len(nums) <= 1:
			return 0
		max1 = max(nums)
		idx = nums.index(max1)
		del nums[idx]
		max2 = max(nums)
		return idx if max2 * 2 <= max1 else -1


class Solution:

	def dominantIndex(self, nums):
		largest = max(nums)
		for n in nums:
			if 2 * n > largest and n != largest:
				return -1
		return nums.index(largest)


class Solution:

	def dominantIndex(self, nums):
		if len(nums) > 1:
			n = max(nums)
			id = nums.index(n)
			nums.remove(n)
			return id if n >= max(nums) * 2 else -1
		else:
			return 0


class Solution:

	def dominantIndex(self, nums):
		if len(nums) == 1:
			return 0
		maxnum = max(nums)
		index = nums.index(maxnum)
		nums.sort()
		if nums[-1] >= nums[-2] * 2:
			return index
		else:
			return -1


class Solution:

	def dominantIndex(self, nums):
		out_index = -1
		(lrgst, scnd, ind) = (-float('inf'), None, None)
		for i in range(len(nums)):
			if nums[i] > lrgst:
				(lrgst, scnd, ind) = (nums[i], lrgst, i)
			elif nums[i] > scnd:
				scnd = nums[i]
		if lrgst >= 2 * scnd:
			out_index = ind
		return out_index


class Solution:

	def dominantIndex(self, nums):
		first = float('-Inf')
		second = float('-Inf')
		index = None
		for (d, num) in enumerate(nums):
			if num > first:
				second = first
				first = num
				index = d
			if second < num < first:
				second = num
		if second == 0 or second == float('-Inf') or first / second >= 2:
			return index
		else:
			return -1


class Solution:

	def dominantIndex(self, nums):
		if len(nums) == 1:
			return 0
		doubleBigIndex = 0
		halfpoint = 0
		biggest = 0
		for (index, item) in enumerate(nums):
			print((biggest, halfpoint, doubleBigIndex, item))
			if item >= 2 * biggest:
				biggest = item
				doubleBigIndex = index
				halfpoint = biggest / 2.0
			elif item > halfpoint:
				doubleBigIndex = -1
			print(doubleBigIndex)
		return doubleBigIndex


class Solution:

	def dominantIndex(self, nums):
		n = len(nums)
		if n <= 1:
			return n - 1
		im = 0
		im2 = 1
		if nums[im2] > nums[im]:
			(im, im2) = (im2, im)
		for i in range(2, n):
			if nums[i] > nums[im]:
				im2 = im
				im = i
			elif nums[i] > nums[im2]:
				im2 = i
		if nums[im] >= nums[im2] * 2:
			return im
		else:
			return -1


class Solution:

	def dominantIndex(self, nums):
		if len(nums) == 1:
			return 0
		Max = max(nums)
		if nums.count(Max) > 1:
			return -1
		if any(nums) == False:
			return 0
		if nums.count(0) == len(nums) - 1:
			return nums.index(Max)
		for i in nums:
			if i != Max and i != 0:
				if Max / i < 2:
					return -1
		return nums.index(Max)