Skip to content

Commit cd5e91a

Browse files
committed
adding new algo
1 parent 32bc11f commit cd5e91a

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import List, Union, Collection, Mapping, Optional
2+
from abc import ABC, abstractmethod
3+
4+
class Solution:
5+
def minimumSwaps(self, nums: List[int]) -> int:
6+
7+
min_num = min(nums)
8+
max_num = max(nums)
9+
10+
id_min = nums.index(min_num)
11+
12+
new_nums = [min_num] + nums[:id_min] + nums[id_min+1:]
13+
14+
id_max = new_nums[::-1].index(max_num)
15+
16+
return id_min + id_max

0 commit comments

Comments
 (0)