-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgfg_potd
More file actions
21 lines (16 loc) · 703 Bytes
/
Copy pathgfg_potd
File metadata and controls
21 lines (16 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
You will be given an array arr of integers of length N. You can construct an integer from two integers by treating the integers as strings, and then concatenating them. For example, 19 and 4 can be used to construct 194 and 419.
The task is to find whether it’s possible to construct an integer using all the digits of these numbers such that it would be divisible by 3.
If it is possible then print 1 and if not print 0.
class Solution:
def isPossible(self, N, arr):
# code here
s=''
for i in arr:
s+=str(i)
sum=0
for j in s:
sum+=int(j)
if sum%3==0:
return 1
else:
return 0