@@ -352,7 +352,7 @@ def first_not_repeating_character(s: str) -> str:
352352 if char not in checked_chars and s.index(char) == s.rindex(char):
353353 return char
354354 checked_chars.add(char)
355- return ' _ '
355+ return " _ "
356356```
357357
358358With Array Slices (less optimal):
@@ -362,10 +362,10 @@ def first_not_repeating_character(s: str) -> str:
362362 length = len (s)
363363 index = 0
364364 while index < length:
365- if s[index] not in s[:index] and s[index] not in s[index + 1 :]:
365+ if s[index] not in s[:index] and s[index] not in s[index + 1 :]:
366366 return s[index]
367367 index += 1
368- return ' _ '
368+ return " _ "
369369```
370370
371371## First Pivot Index
@@ -500,7 +500,6 @@ def largest_number_at_least_twice_of_others(nums: [int]) -> int:
500500 if next_largest is None or (nums[next_largest] * 2 ) <= nums[largest]:
501501 return largest
502502 return - 1
503-
504503```
505504
506505With array manipulation and built-in functions. Slightly slower but easier to read
@@ -596,7 +595,9 @@ Input:
596595Output: ` [1,2,2,3,5,6] `
597596
598597``` python
599- def merge_sorted_array (nums1 : List[int ], nums1_length : int , nums2 : List[int ], nums2_length : int ) -> List[int ]:
598+ def merge_sorted_array (
599+ nums1 : List[int ], nums1_length : int , nums2 : List[int ], nums2_length : int
600+ ) -> List[int ]:
600601 index_nums1 = nums1_length - 1
601602 index_nums2 = nums2_length - 1
602603 current_index = nums1_length + nums2_length - 1
@@ -905,6 +906,7 @@ def rotate_array_in_place(nums: List[int], k: int) -> List[int]:
905906 reverse(nums, k, length - 1 )
906907 return nums
907908
909+
908910def reverse (arr : List, start , end ):
909911 while start < end:
910912 arr[start], arr[end] = arr[end], arr[start]
@@ -1095,9 +1097,9 @@ def third_max(nums: List[int]) -> int:
10951097 if len (unique_nums) < 3 :
10961098 return max (unique_nums)
10971099
1098- unique_nums.remove(max (unique_nums)) # 1st
1099- unique_nums.remove(max (unique_nums)) # 2nd
1100- return max (unique_nums) # 3rd
1100+ unique_nums.remove(max (unique_nums)) # 1st
1101+ unique_nums.remove(max (unique_nums)) # 2nd
1102+ return max (unique_nums) # 3rd
11011103```
11021104
11031105## Two Sum
0 commit comments