Problem
Integrity Score
Learn this problemProblem statement
A data packet is represented as a string dataPacket of lowercase English letters. Each character has the following value:
aandbhave value1.c,d, andehave value2.f,g, andhhave value3.i,j, andkhave value4.l,m, andnhave value5.o,p, andqhave value6.r,s, andthave value7.u,v, andwhave value8.x,y, andzhave value9.
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) → longExamples
Example 1
dataPacket = "cat"return = 4The 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^5dataPacketconsists of lowercase English letters.
More Salesforce problems
- Minimize Total Input Cost (for LTMS)Seen Jun 2026
- Count Prime StringsONSITE INTERVIEW · Seen Jun 2026
- Final Pod Counts After LogsOA · Seen May 2026
- ATM Queue Exit OrderPHONE SCREEN · Seen May 2026
- Good Ways to Split an ArrayPHONE SCREEN · Seen May 2026
- Generate Seen Binary StringsOA · Seen May 2026
- Update Pod Counts From LogsOA · Seen May 2026
- Minimum Removals to Balance ArrayOA · Seen May 2026