Skip to content

Instantly share code, notes, and snippets.

@Jam6808
Created August 2, 2012 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jam6808/3234737 to your computer and use it in GitHub Desktop.
Save Jam6808/3234737 to your computer and use it in GitHub Desktop.
def not_alone(nums, val):
for e in nums:
if e == val:
s = nums.index(e)
if s != 0 and s != (len(nums) - 1):
nums[s] = max(nums[s-1], nums[s+1])
return nums
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment