You are going to book a taxi. There are infinite number of points 1, 2, 3... on the X axis and your current position is cur. There are N Taxis near you, and the position of those taxis is given as an array pos. Where pos[i] denotes the position of the ith taxi. You are also given an array time. Where time[i] denotes the time taken by the ith taxi to cover 1 unit of distance. Your task is to find the minimum time to board a taxi.
Example 1:
Input:
N = 3, cur = 4
pos = [1, 5, 6]
time = [2, 3, 1]
Output:
2
Explanation:
Total time taken by the 1st taxi will be: (4-1)*2 = 6
Total time taken by the 2nd taxi will be: (5-4)*3 = 3
Total time taken by the 3rd taxi will be: (6-4)*1 = 2
So, the minimum time will be 2 sec.
 
Example 2:
Input:
N = 2, cur = 1
pos = [1, 6]
time = [10, 3]
Output:
0
Explanation:
Total time taken by the 1st taxi will be: (1-1)*10 = 0
Total time taken by the 2nd taxi will be: (6-1)*3 = 15
So, the minimum time will be 0 sec.
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function minimumTime() which takes two integers N and cur, and 2 arrays pos, and time as input parameters and returns the minimum time required to board the taxi.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{5}
1 ≤ cur ≤ 10^{5}
1 ≤ pos[i] ≤ 10^{5}
1 ≤ time[i] ≤ 10^{3}

Difficulty: EASY
Tags: Data structures

Greedy algorithms
Skill types: Data structures

Greedy algorithms
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Starter code:
from typing import List





class Solution:

    def minimumTime(self, N : int, cur : int, pos : List[int], time : List[int]) -> int:

        # code here

        



Solutions:
from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		q = []
		for i in range(len(pos)):
			q.append(abs(pos[i] - cur) * time[i])
		return min(q)


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		l = []
		for i in range(0, N):
			s = abs(cur - pos[i])
			ans = s * time[i]
			l.append(ans)
		return min(l)


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		m = 10000000
		for i in range(len(pos)):
			t = abs(cur - pos[i]) * time[i]
			if t < m:
				m = t
		return m


from typing import List
import sys

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		max = sys.maxsize
		d = 0
		for i in range(N):
			d = abs(cur - pos[i]) * time[i]
			if d < max:
				max = d
		return max


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		answer = 10000000
		for i in range(len(pos)):
			a = abs(cur - pos[i])
			a *= time[i]
			answer = min(answer, a)
		return answer


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		ans = 10000000000.0
		for i in range(len(pos)):
			ans = min(ans, abs(cur - pos[i]) * time[i])
		return ans


from typing import List
import sys

class Solution:

	def minimumTime(self, N: int, cur: int, a: List[int], time: List[int]) -> int:
		min = sys.maxsize
		for i in range(0, N):
			if cur > pos[i]:
				sum = (cur - pos[i]) * time[i]
			else:
				sum = (pos[i] - cur) * time[i]
			if sum < min:
				min = sum
		return min


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		min = float('inf')
		for i in range(N):
			if abs(pos[i] - cur) * time[i] < min:
				min = abs(pos[i] - cur) * time[i]
		return min


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		lst = []
		for i in range(N):
			x = abs(cur - pos[i]) * time[i]
			lst.append(x)
		return min(lst)


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		a = []
		for i in range(N):
			b = abs((cur - pos[i]) * time[i])
			a.append(b)
		return min(a)


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		s = []
		for i in range(N):
			if pos[i] > cur:
				s.append((pos[i] - cur) * time[i])
			else:
				s.append((cur - pos[i]) * time[i])
		return min(s)


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		m = 10 ** 9
		for i in range(N):
			m = min(abs(cur - pos[i]) * time[i], m)
		return m


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		t = []
		for i in range(N):
			d = abs((pos[i] - cur) * time[i])
			t.append(d)
		return min(t)


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		ms = -1
		for x in range(N):
			s = (cur - pos[x]) * time[x]
			if s < 0:
				s = s * -1
			if ms == -1:
				ms = s
			elif ms > s:
				ms = s
		return ms


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		min = 999999999
		for i in range(0, N):
			x = abs(pos[i] - cur) * time[i]
			if x < min:
				min = x
		return min


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		r = []
		for i in range(0, N):
			p = abs(cur - pos[i]) * time[i]
			r.append(p)
		return min(r)


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		l1 = []
		i = 0
		while i < N:
			x = abs(cur - pos[i]) * time[i]
			l1.append(x)
			i += 1
		m = min(l1)
		return m


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		list1 = []
		for i in range(0, len(pos)):
			d = abs(cur - pos[i]) * time[i]
			list1.append(d)
		m = min(list1)
		return m


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		b = [0 for x in range(len(pos))]
		for i in range(len(pos)):
			if pos[i] < cur:
				b[i] = (cur - pos[i]) * time[i]
			if pos[i] > cur:
				b[i] = (pos[i] - cur) * time[i]
		b.sort()
		return b[0]


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		import math
		return min((time[x] * abs(pos[x] - cur) for x in range(N)))


from typing import List

class Solution:

	def minimumTime(self, n: int, cur: int, pos: List[int], time: List[int]) -> int:
		res = float('inf')
		for i in range(0, n):
			res = min(res, abs(cur - pos[i]) * time[i])
		return res


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		k = []
		for i in range(N):
			m = abs(pos[i] - cur) * time[i]
			k.append(m)
		return min(k)


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		mtime = 100000000.0
		for i in range(N):
			mtime = min(mtime, abs(pos[i] - cur) * time[i])
		return mtime


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		res = 9999999
		for i in range(len(pos)):
			if cur >= pos[i]:
				res = min(res, (cur - pos[i]) * time[i])
			else:
				res = min(res, (pos[i] - cur) * time[i])
		return res


from typing import List
import sys

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		res = sys.maxsize
		for i in range(N):
			res = min(res, abs(cur - pos[i]) * time[i])
		return res


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		min_time = float('inf')
		for i in range(len(pos)):
			dist = abs(cur - pos[i])
			travel_time = dist * time[i]
			min_time = min(min_time, travel_time)
		return min_time


from typing import List
import sys

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		mn = sys.maxsize
		for i in range(N):
			temp = abs(cur - pos[i]) * time[i]
			if temp < mn:
				mn = temp
		return mn


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		tem1 = 0
		ans = []
		for i in range(0, N):
			tem1 = cur - pos[i]
			if tem1 < 0:
				tem1 = tem1 * -1
			tem1 = tem1 * time[i]
			ans.append(tem1)
		return min(ans)


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		res = min([abs(x - cur) * t for (x, t) in list(zip(pos, time))])
		return res


from typing import List

class Solution:

	def minimumTime(self, n: int, cur: int, pos: List[int], time: List[int]) -> int:
		mini = 10000000000000
		for i in range(n):
			mini = min(mini, abs(cur - pos[i]) * time[i])
		return mini


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		a = []
		for (i, j) in zip(pos, time):
			a.append(abs(cur - i) * j)
		return min(a)


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		minimum = float('inf')
		for (p, t) in zip(pos, time):
			minimum = min(minimum, t * abs(p - cur))
		return minimum


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		li = []
		j = 0
		for i in range(N):
			li.append(abs(cur - pos[i]) * time[j])
			j += 1
		return min(li)


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		mn = 999999999
		for i in range(N):
			mn = min(mn, abs(pos[i] - cur) * time[i])
		return mn


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		fastest = 100000000
		for i in range(len(pos)):
			fastest = min(abs(cur - pos[i]) * time[i], fastest)
		return fastest


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		assert N == len(pos)
		assert N == len(time)
		wait_time = float('inf')
		for i in range(N):
			wait = abs(cur - pos[i]) * time[i]
			if wait < wait_time:
				wait_time = wait
		return wait_time


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:

		def minimumTime(N, cur, pos, time):
			import numpy as np
			q = len(time)
			lst = []
			for i in range(q):
				t = np.abs((cur - pos[i]) * time[i])
				lst.append(t)
			m = min(lst)
			return m

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		mn = 10 ** 9
		for i in range(N):
			dist = abs(pos[i] - cur)
			mn = min(mn, dist * time[i])
		return mn


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		m = abs(cur - pos[0]) * time[0]
		i = 1
		while i < N:
			c = abs(cur - pos[i]) * time[i]
			m = min(m, c)
			i += 1
		return m


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:

		def minimumTime(N, cur, pos, time):
			min_time = float('inf')
			for i in range(N):
				taxi_time = abs(cur - pos[i]) * time[i]
				if taxi_time < min_time:
					min_time = taxi_time
			return min_time

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		mn = 10 ** 9
		for i in range(N):
			dist = abs(pos[i] - cur)
			mn = min(mn, dist * time[i])
		return mn


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		mini = 10000001
		for i in range(N):
			mini = min(abs(cur - pos[i]) * time[i], mini)
		return mini


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		min_ = 999999999999999999999999
		for i in range(N):
			min_ = min(abs(pos[i] - cur) * time[i], min_)
		return min_


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		min1 = 99999999999
		for i in range(N):
			m = abs(pos[i] - cur) * time[i]
			if m < min1:
				min1 = m
		return min1


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		minn = abs(cur - pos[0]) * time[0]
		for i in range(N):
			temp = abs(cur - pos[i]) * time[i]
			if minn > temp:
				minn = temp
		return minn


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		m = 67899666
		for i in range(N):
			c = abs(cur - pos[i]) * time[i]
			if c <= m:
				m = c
		return m


from typing import List

class Solution:

	def minimumTime(self, N: int, cur: int, pos: List[int], time: List[int]) -> int:
		lowest = 25 ** 10
		for i in range(N):
			dist = abs(cur - pos[i])
			if lowest > dist * time[i]:
				lowest = dist * time[i]
		return lowest