diff --git "a/leetcode3/\353\263\200\354\247\200\355\230\221/v3/3613. Minimize Maximum Component Cost.py" "b/leetcode3/\353\263\200\354\247\200\355\230\221/v3/3613. Minimize Maximum Component Cost.py" new file mode 100644 index 00000000..e69de29b diff --git "a/leetcode3/\353\263\200\354\247\200\355\230\221/v3/4070. Minimum Rotations to Dial a Number I.py" "b/leetcode3/\353\263\200\354\247\200\355\230\221/v3/4070. Minimum Rotations to Dial a Number I.py" new file mode 100644 index 00000000..7440d512 --- /dev/null +++ "b/leetcode3/\353\263\200\354\247\200\355\230\221/v3/4070. Minimum Rotations to Dial a Number I.py" @@ -0,0 +1,23 @@ +class Solution: + def minRotations(self, s: str) -> int: + dic = { + 0: {0:0,1:1,2:2,3:3,4:4,5:5,6:4,7:3,8:2,9:1}, + 1: {1:0,2:1,3:2,4:3,5:4,6:5,7:4,8:3,9:2,0:1}, + 2: {2:0,3:1,4:2,5:3,6:4,7:5,8:4,9:3,0:2,1:1}, + 3: {3:0,4:1,5:2,6:3,7:4,8:5,9:4,0:3,1:2,2:1}, + 4: {4:0,5:1,6:2,7:3,8:4,9:5,0:4,1:3,2:2,3:1}, + 5: {5:0,6:1,7:2,8:3,9:4,0:5,1:4,2:3,3:2,4:1}, + 6: {6:0,7:1,8:2,9:3,0:4,1:5,2:4,3:3,4:2,5:1}, + 7: {7:0,8:1,9:2,0:3,1:4,2:5,3:4,4:3,5:2,6:1}, + 8: {8:0,9:1,0:2,1:3,2:4,3:5,4:4,5:3,6:2,7:1}, + 9: {9:0,0:1,1:2,2:3,3:4,4:5,5:4,6:3,7:2,8:1}, + } + + ans = 0 + curr = 0 + + for i in s: + ans += dic[curr][int(i)] + curr = int(i) + + return ans \ No newline at end of file