Salesforce Software Engineer Coding & Algorithms Interview Questions
Practice the exact questions companies are asking right now.
Determine minimal substitutions and removals
Question Given a list of words, determine the minimum number of character substitutions required so that, in every word, no two adjacent characters ar...
Remove duplicates in linked list
Question Given a linked list, remove all duplicate values so that each value appears only once. Provide solutions for both sorted and unsorted linked ...
Convert integer to NAF form
Question Convert a given integer into its Non-Adjacent Form (NAF) representation such that no two non-zero digits are adjacent, and prove that the res...
Solve array duplicate flags and binary swaps
Problem 1: Flag duplicates on the left and right You are given an integer array nums of length n. For each index i, determine: 1. Left-duplicate: whet...
Implement an LFU cache
Problem: LFU Cache Design and implement a Least Frequently Used (LFU) cache with a fixed capacity. The cache supports the following operations: - get(...
Remove duplicates from a singly linked list
You are given the head of a singly linked list of integers. Modify the list in place so that it contains only the first occurrence of each value (i.e....
Find longest subsequence of x that is a substring of y
Given two strings x and y, compute the maximum length of a string s such that: - s is a subsequence of x (can delete zero or more characters from x wi...
Flatten nested JSON into a string map
Problem You are given an input JSON object that may contain nested objects and arrays. Your task is to flatten it into a single-level key/value mappin...
Minimize steps to reduce integer
Given a positive integer n (1 <= n <= 2^61 - 1), in one step you may replace n with n/2 if n is even, or with n+1 or n-1 if n is odd. Return the minim...
Design O(nm) grouping of rearranged strings
Given an array of strings, group together words that are permutations of the same characters. Provide a baseline solution that sorts each word (O(n · ...
Implement 64-bit modular exponentiation safely
Implement a function to compute (a^b) mod m where 0 ≤ a,b < 2^61−1 and 1 ≤ m < 2^61−1 using only 64-bit operations without overflow. Provide implement...
Deduplicate a Linked List
Given a singly linked list, remove duplicate values in-place. Variant A (sorted list): delete repeated nodes so each value appears once using O( 1) ex...
Convert Integer to Non-Adjacent Form
Implement toNAF(n) that converts an integer n (allow negative n) to its Non-Adjacent Form using digits from {-1, 0, 1} with no two adjacent nonzero di...