Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Fei Chen
Got easier solution(python)

Fei Chen

Apr 16, 2024

import math class Solution: def sort(self, arr): sorted_arr = sorted(arr) if sorted_arr == arr or len(arr) == 1: return 0 l, r = 0, len(arr) - 1 while l <= r: if arr[l] == sorted_arr[l]: l+= 1 elif arr[r] == sorted_arr[r]: r -= 1 else: break return r-l+1

0

0

Comments
Comments

On this page