
Salesforce


Salesforce Associate Software Engineer Interview Questions and Answers
Q1. Factorial Trailing Zeros Problem
You are provided with a positive integer N. Your goal is to determine the smallest number whose factorial has at least N trailing zeros.
Example:
Input:
N = 1
Output:
5
Explanat...read more
Find the smallest number whose factorial has at least N trailing zeros.
Calculate the number of 5's in the prime factorization of the factorial to determine the trailing zeros.
Use binary search to find the smallest number with at least N trailing zeros.
Consider edge cases like N = 0 or N = 1 for factorial trailing zeros problem.
Q2. Combination Sum Problem Statement
Given three integers X
, Y
, and Z
, calculate the sum of all numbers that can be formed using the digits 3, 4, and 5. Each digit can be used up to a maximum of X
, Y
, and Z
times ...read more
Calculate the sum of all numbers that can be formed using the digits 3, 4, and 5 with given constraints.
Iterate through all possible combinations of 3, 4, and 5 based on the given constraints.
Calculate the sum of each combination and add them up.
Return the final sum modulo 10^9 + 7.
Q3. Reverse Linked List Problem Statement
Given a singly linked list of integers, your task is to return the head of the reversed linked list.
Example:
Input:
The given linked list is 1 -> 2 -> 3 -> 4 -> NULL.
Outp...read more
To reverse a singly linked list of integers, return the head of the reversed linked list.
Iterate through the linked list, reversing the pointers to point to the previous node instead of the next node.
Keep track of the previous, current, and next nodes while traversing the list.
Update the head of the reversed linked list to be the last element of the original list.
Q4. Longest Path In Directed Graph Problem Statement
Given a Weighted Directed Acyclic Graph (DAG) comprising 'N' nodes and 'E' directed edges, where nodes are numbered from 0 to N-1, and a source node 'Src'. Your ...read more
The task is to find the longest distances from a source node to all nodes in a weighted directed acyclic graph.
Implement a function that takes the number of nodes, edges, source node, and edge weights as input.
Use a topological sorting algorithm to traverse the graph and calculate the longest distances.
Return an array of integers where each element represents the longest distance from the source node to the corresponding node.
Q5. Largest BST Subtree Problem
Given a binary tree with 'N' nodes, determine the size of the largest subtree that is also a BST (Binary Search Tree).
Input:
The first line contains an integer 'T', representing the...read more
The problem involves finding the size of the largest subtree that is also a Binary Search Tree in a given binary tree.
Traverse the binary tree in a bottom-up manner to check if each subtree is a BST.
Keep track of the size of the largest BST subtree encountered so far.
Use recursion to solve the problem efficiently.
Consider edge cases like empty tree or single node tree.
Example: For input 1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1, the largest BST subtree has size 3.
Q6. Implementing a Priority Queue Using Heap
Ninja has been tasked with implementing a priority queue using a heap data structure. However, he is currently busy preparing for a tournament and has requested your ass...read more
Implement a priority queue using a heap data structure by completing the provided functions: push(), pop(), getMaxElement(), and isEmpty().
Understand the operations: push() to insert element, pop() to remove largest element, getMaxElement() to return largest element, and isEmpty() to check if queue is empty.
Implement a heap data structure to maintain the priority queue.
Handle different types of queries based on the input provided.
Ensure correct output for each type 3 query.
Te...read more
Design a system similar to Splitwise and suggest three features for improvement.
Implement a real-time notification system for updates on shared expenses
Integrate a feature for automatic currency conversion for international transactions
Enhance the user interface with data visualization tools for better expense tracking
More about working at Salesforce





Top Associate Software Engineer Interview Questions from Similar Companies







Reviews
Interviews
Salaries
Users/Month

