I am stuck on this problem
Given an array of ints, return True if the array contains a 2 next to a 2 somewhere.
has22([1, 2, 2]) → True
has22([1, 2, 1, 2]) → False
has22([2, 1, 2]) → False
I know the basic idea (there are syntax errors) but I can't implement it. I would also like to know what type of problem this is, eg. graph, search?
def has22(nums):
for x in nums:if ( (nums[x] = 2) and (nums[x+1] = 2) )return Truereturn False