king_crimson10

reverse_subarray

Apr 9th, 2022
888
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def canBeEqual(self, target: List[int], arr: List[int]) -> bool:
  2.     target_map = {}
  3.     arr_map = {}
  4.     for i in range(len(target)):
  5.         if target[i] not in target_map:
  6.             target_map[target[i]] = 1
  7.         else:
  8.             target_map[target[i]] += 1            
  9.         if arr[i] not in arr_map:
  10.             arr_map[arr[i]] = 1
  11.         else:
  12.             arr_map[arr[i]] +=1
  13.        
  14.     if(target_map==arr_map):
  15.         return True
  16.     else:
  17.         return False
Advertisement
Add Comment
Please, Sign In to add comment