FastPrepIntegrity Score
Problems/Integrity Score

Integrity Score

Salesforce logoSalesforceFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

A data packet is represented as a string dataPacket of lowercase English letters. Each character has the following value:

  • a and b have value 1.
  • c, d, and e have value 2.
  • f, g, and h have value 3.
  • i, j, and k have value 4.
  • l, m, and n have value 5.
  • o, p, and q have value 6.
  • r, s, and t have value 7.
  • u, v, and w have value 8.
  • x, y, and z have value 9.

The integrity score is the number of substrings whose character-value sum is divisible by the substring length. Return the integrity score of dataPacket as a long.

Function

integrityScore(dataPacket: String) → long

Examples

Example 1

dataPacket = "cat"return = 4

The character values are [2, 1, 7]. The valid substrings are "c", "a", "t", and "at". The substring "at" has sum 8 and length 2, so its sum is divisible by its length.

Constraints

  • 1 <= dataPacket.length <= 10^5
  • dataPacket consists of lowercase English letters.

More Salesforce Online Assessment questions

  • Count Subarrays With Product Equal to KOA · Seen Nov 2026
  • Minimum No-Repeat Segments After One Character RemovalOA · Seen Nov 2026
  • Get Message StatusOA · Seen Nov 2026
  • Minimum Unique-Character Segments After DeletionOA · Seen Sep 2026
  • Run-Length String CompressionOA · Seen Sep 2026
  • Maximum Requests in WindowOA · Seen Sep 2026
  • Final Pod Counts After LogsOA · Seen Aug 2026
  • Minimum Removals to Balance ArrayOA · Seen Aug 2026
  • Is This Date a Weekend?OA · Seen Aug 2026
  • Maximum Barbell WeightOA · Seen Jul 2026

Salesforce interview experiences

  • Salesforce Infrastructure SWE OA and Onsite: 1 Experience
  • Salesforce Experienced Backend SWE First Round: 1 Experience
All Salesforce interview questionsSee Salesforce hiring insights
Saved
class Solution {
    public long integrityScore(String dataPacket) {
      // write your code here
    }
}
Checking account…