Given an array numbs of integers, you can perform operations on the array. If each operations, you pick any nums[i] and delete it to earn nums[i] points.
After, you must delete every element equal to nums[i]-1 or nums[i]+1.
You start with 0 points. Return the maximum number of points you can earn by applying such operations.
numb=list(map(int,input('Enter the array numbers: ').split(' '))) a=int(len(numb)/2) for i in range(0,len(numb)): if(a<len(numb)): for j in range(0,len(numb)): if(a<len(numb)): if((numb[j]== numb[a]-1) or (numb[j]==numb[a]+1)): numb[j]=0 if(a<len(numb)): a+=1 points=0 for i in range(len(numb)): points+=numb[i] print(points)
Input:
Enter the array numbers: 3 4 2
Output:
6
Output:
Enter the array numbers: 3 4 2
6
Output:
Enter the array numbers: 6 5 2 0
13
Output:
Enter the array numbers: 8 9 5 6 2
24
Output:
Enter the array numbers: 10 100 1000 20
1130
Output:
Enter the array numbers: 65 20 30
115
Output:
Enter the array numbers: 1 1 2 1
2
Output:
Enter the array numbers: 0 1 2 3 4 5
8
Output:
Enter the array numbers: 1 2 3 4 5
8
Output:
Enter the array numbers: 3 2 100
102
More Codes to Fcuk
- Armstrong Number
- Find the biggest even number
- Program to replace every element on right side
- Compute the frequency of the note
- Print all Possible Combinations from three Digits.
- Get number n and Compute n+nn+nnn
- Print Cube root of the given number
- Convert number into binary, octal and hexa
- Return maximum number of operations performed on array.
- Determine the encryption key
- Find the count of numbers having a prime number in their binary representation.
- Fibonacci Series up to given n numbers
- Help Alice find the route to her home
- Quantum Mechanics relation with quantum computing
- Unzipping Files using Python
- An Algorithm which accepts n integer values and calculates the average and prints it.
- How can Quantum Computing merge with Virtual Reality ? !
- Blockchain and Cryptocurrency. And their relations with Virtual Reality !!