Salesforce | SMTS | Reject

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-07-08Added By Anonymous
Source: Link

Company: Salesforce
Role: senior mts
Interview Stage: Onsite
Location: Bangalore
Year: 2025

Original Post Content:

Hi Folks,

YOE: 6
Currently SSE @ Walmart

Recently gave OA for SMTS position at Salesforce India.
Got the OA link after cold emailing a bunch of salesforce recruiters.

Date: 8th July 2025

#1: Minimum Operations to Zero
(Same as LeetCode problem #2571.)
You are given an integer n. In one operation, you can either add or subtract any power of 2 (i.e., ±2&sup0;, ±2¹, ±2², ..., ±2&supk;) to/from n.

Write a function that returns the minimum number of such operations required to reduce n to 0.
public static int getMinOperations(int n)

Input: A single integer n (1 ≤ n ≤ 10⁹)
Output: An integer representing the minimum number of operations to reduce n to 0.

Example:
Input: 21
Output: 3

Explanation:
21 → 20 (subtract 1 = 2&sup0;)
20 → 16 (subtract 4 = 2²)
16 → 0 (subtract 16 = 2&sup4;)

#2: Integrity Score
A data packet is represented as a string of lowercase English letters. The integrity score of the packet is defined as the number of substrings whose character values sum to a number divisible by the length of the substring.

Each character is assigned a value as follows:
a,b -> 1
c,d,e -> 2
f,g,h -> 3
i,j,k -> 4
l,m,n -> 5
o,p,q -> 6
r,s,t -> 7
u,v,w -> 8
x,y,z -> 9

Write a function that returns the integrity score of the packet.
public static int integrityScore(String dataPacket)

Input: A string dataPacket consisting of lowercase English letters (1 ≤ length ≤ 10⁵)
Output: An integer representing the integrity score.

Example:
Input: "cat"
Output: 4

Solution:
public static int integrityScore(String dataPacket) {
int n = dataPacket.length();
int[] prefixSum = new int[n + 1];
int count = 0;

// Build prefix sum using custom mapping: 'a' = 1 etc
for (int i = 0; i < n; i++) {
char ch = dataPacket.charAt(i);
prefixSum[i + 1] = prefixSum[i] + getValue(ch);
}

// Check all substrings
for (int start = 0; start < n; start++) {
for (int end = start + 1; end <= n; end++) {
int length = end - start;
int sum = prefixSum[end] - prefixSum[start];
if (sum % length == 0) {
count++;
}
}
}

return count;
}
private static int getValue(char ch) {
return switch (ch) {
case 'a','b' -> 1;
case 'c','d','e' -> 2;
case 'f','g','h' -> 3;
case 'i','j','k' -> 4;
case 'l','m','n' -> 5;
case 'o','p','q' -> 6;
case 'r','s','t' -> 7;
case 'u','v','w' -> 8;
case 'x','y','z' -> 9;
default -> 0;
};
}

Cleared and asked to appear for F2F rounds.

Date: 26th July 2025

Round #1 (Onsite) : DSA
Interviewer mentioned that this role is for Industries Cloud.

You are given an array ratings[] of integers where each element represents the rating of a movie. You want to watch movies in a way that maximizes the total rating, but with the following constraint:
You cannot skip more than one movie consecutively.

Rules:
You may choose to watch or skip any movie.
Skipping two or more movies in a row is not allowed.
Your goal is to select a subset of movies such that the sum of their ratings is maximized, while respecting the skip constraint.
&#128229; Input:
An integer array ratings[] of length n where -1000 ≤ ratings[i] ≤ 1000.
&#128230; Output:
Return the maximum possible sum of ratings you can achieve.
&#129517; Example:
Input: ratings = {-3, 2, 4, -1, -2, -5}
Output: 4

Attempted with brute force approach, couldn't clear all test cases, hence rejected.

#salesforce #smts #oa #onsite #bangalore

Comments