Questions asked in salesforce

Questions asked in salesforce (HackerRank Test) for the role of Technical Support Engineer.

Question 1:
Flip binary input for Maximum 1's

Given an array All consisting of 0's and 1's. A flip operation is one in which you turn 1 into 0 and a 0 into 1. You have to do at most one "Flip" operation of any subarray.
Formally, select a range (I, r) in the array AD of size n, such that (0 < I sr < n) holds and flip the elements in this range to get the maximum ones in the final array.
You can possibly make zero operations to get the answer.
You are asked to return the maximum number of 1's you can get in the array after doing flip operation.
Example 1:
Input:
N=5
AD = (1, 0, 0, 1, 0}
Output:
4
Explanation:
We can perform a flip operation in the range [1,2]
After flip operation array is : [ 1 1 1 1 0 ]
Count of one after fliping is : 4
[Note: the subarray marked in bold is the flipped subarray]

Question 2:

India, being a cricket-crazy nation, shares Sarfaraz's passion for the sport and the analytical aspect of it. Sarfaraz, an ardent cricket enthusiast, has developed a Cricket app that specializes in evaluating cricketers' performances. The app assigns a negative rating to under-performing cricketers and rewards a positive rating to those who excel. Sarfaraz's primary objective is to analyze the performance of a cricketer across a span of N matches and determine their consistency. He aims to identify the maximum cumulative cricket rating achieved by a batsman or a bowler, but only if their overall rating remains positive throughout the given period. Can you assist Sarfaraz in accomplishing this task?
Note: Return maximum consistent sum of rating of the cricketer if positive else 0 (zero).
Constraints:
• 0 <= N(matches) <= 105
• -10 <= ratings <= 10
5
6
7
Sample Input
The first parameter contains the number of matches (numberOfMatchesPlayed) over which the analysis is to be done. The second line contains those ratings (ratingReceivedinEachMatch) of a batsman/bowler in those matches.

Sample Output
Return maximum consistent sum of rating of the cricketer if positive else 0 (zero).

Comments (6)