diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..ac33aa4 Binary files /dev/null and b/.DS_Store differ diff --git a/main2.py b/main2.py index 2f6ad21..cc791ce 100644 --- a/main2.py +++ b/main2.py @@ -2,7 +2,11 @@ def oddOrEven(nums): '''Given an unsorted list of numbers, return a list that indicates if the value at each index is odd (0) or even (1).''' # EXAMPLE: # Given [2, 4, 5, 7, 8, 10], return [1, 1, 0, 0, 1, 1] - return [] + list = [] + for num in nums: + list.append(((num)+1)%2) + + return list def mostOccurences(nums): @@ -10,8 +14,18 @@ def mostOccurences(nums): # Hint: use oddOrEven to test function faster # Hint: use a map # Hint: https://stackoverflow.com/questions/13098638/how-to-iterate-over-the-elements-of-a-map-in-python - return -1 + greatest = 0 + mp={} + for i in nums : + if i in mp : + mp[i] += 1; + else : + mp[i] = 1; + for i in mp: + if(i > greatest): + greatest = i + return greatest def main(): '''The main function is where you will test all of your functions.''' @@ -23,4 +37,4 @@ def main(): # Add any additional test cases if needed if __name__ == "__main__": - main() \ No newline at end of file + main()