-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncryptedIntegers.java
More file actions
50 lines (48 loc) · 1.14 KB
/
EncryptedIntegers.java
File metadata and controls
50 lines (48 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<<<<<<< HEAD
//3079. Find the Sum of Encrypted Integers
class Solution {
public int encrypt(int n){
int max = 0, len = 0;
String num = new String();
while(n>0){
if(n % 10 > max) max = n%10;
n/=10;
len++;
}
for(int i=0;i<len;i++){
num = num + max;
}
return Integer.parseInt(num);
}
public int sumOfEncryptedInt(int[] nums) {
int sum = 0;
for(int num : nums){
sum += encrypt(num);
}
return sum;
}
=======
//3079. Find the Sum of Encrypted Integers
class Solution {
public int encrypt(int n){
int max = 0, len = 0;
String num = new String();
while(n>0){
if(n % 10 > max) max = n%10;
n/=10;
len++;
}
for(int i=0;i<len;i++){
num = num + max;
}
return Integer.parseInt(num);
}
public int sumOfEncryptedInt(int[] nums) {
int sum = 0;
for(int num : nums){
sum += encrypt(num);
}
return sum;
}
>>>>>>> be6ce0b427078b1421d5dd74adb2300dc02daeec
}