注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
两题 50 分钟, 时间有点不够, 求大米!!
Problem 1:
Write a function:
class Solution ( public int solution(int(] A): }
that, given an array A consisting of N integers, returns the maximum sum
of two numbers whose digits add up to an equal sum. If there are no two
numbers whose digits have an equal sum, the function should return -1.
Examples:
1. Given A = [51, 71, 17, 42], the function should return 93. There are two
pairs of numbers whose digits add up to an equal sum: (51, 42) and (17,
71). The first pair sums up to 93.
2. Given A = [42, 33, 601, the function should return 102. The digits of all
numbers in A add up to the same sum, and choo
3. Given S = "eeee", the function should return O (there is no need to delete
any characters).
4. Given S = "example", the function should return 4.
Write an efficient algorithm for the following assumptions:
N is an integer within the range [0.300,000];
string S consists only of lowercase letters (a-z).
|