PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Salesforce

Solve sliding window, heap, DP, in-place tasks

Last updated: Jun 1, 2026

Quick Overview

This set evaluates proficiency with core algorithmic patterns—sliding-window techniques, heap-based top-k selection, dynamic programming for unbounded combinations, frequency-count windowing for anagrams, and in-place array permutation manipulation—alongside complexity analysis and robust edge-case handling.

  • hard
  • Salesforce
  • Coding & Algorithms
  • Software Engineer

Solve sliding window, heap, DP, in-place tasks

Company: Salesforce

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given several LeetCode-style coding tasks. Implement each with the stated time/space goals and handle edge cases. ## 1) Sliding Window: longest substring with all distinct characters **Input:** a string `s` (ASCII or lowercase letters). **Output:** an integer: the maximum length of a contiguous substring of `s` that contains **no repeated characters**. **Constraints:** target time `O(n)`. --- ## 2) Heap / Top-K: k closest points **Input:** an integer `k` and an array of points `points`, where each point is `(x, y)`. **Output:** any ordering of the **k points** with smallest squared distance to the origin, `x^2 + y^2`. **Constraints:** must be `O(n log k)` time (and `O(k)` extra space besides output). --- ## 3) DP: minimum items to reach a target sum **Input:** an array of positive integers `values` (can reuse each value unlimited times) and an integer `amount`. **Output:** the minimum number of values needed to sum to `amount`; return `-1` if impossible. **Constraints:** explain state definition and initialization clearly; typical target `O(len(values) * amount)` time. --- ## 4) Sliding Window: find all anagram start indices **Input:** strings `s` and `p`. **Output:** all starting indices `i` such that `s[i : i+len(p)]` is a permutation of `p`. **Constraints:** target `O(|s|)` time using a fixed-size window and character counts. --- ## 5) Array in-place: previous permutation with one swap **Input:** an integer array `a`. **Output:** the lexicographically largest array that is **strictly smaller** than `a` and can be obtained by **at most one swap** of two indices. If no such array exists, return `a` unchanged. **Constraints:** in-place, `O(n)` or `O(n log n)`; clearly discuss corner cases (duplicates, already smallest permutation, repeated values near the pivot).

Quick Answer: This set evaluates proficiency with core algorithmic patterns—sliding-window techniques, heap-based top-k selection, dynamic programming for unbounded combinations, frequency-count windowing for anagrams, and in-place array permutation manipulation—alongside complexity analysis and robust edge-case handling.

Related Interview Questions

  • Minimum Sum of Weekly Maximum Costs - Salesforce
  • Solve Two OA Coding Problems - Salesforce (medium)
  • Maximize events attended given date ranges - Salesforce (medium)
  • Implement common data-structure and JS tasks - Salesforce (medium)
  • Minimize operations to reduce integer to zero - Salesforce (medium)
Salesforce logo
Salesforce
Jan 22, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
27
0
Loading...

You are given several LeetCode-style coding tasks. Implement each with the stated time/space goals and handle edge cases.

1) Sliding Window: longest substring with all distinct characters

Input: a string s (ASCII or lowercase letters).

Output: an integer: the maximum length of a contiguous substring of s that contains no repeated characters.

Constraints: target time O(n).

2) Heap / Top-K: k closest points

Input: an integer k and an array of points points, where each point is (x, y).

Output: any ordering of the k points with smallest squared distance to the origin, x^2 + y^2.

Constraints: must be O(n log k) time (and O(k) extra space besides output).

3) DP: minimum items to reach a target sum

Input: an array of positive integers values (can reuse each value unlimited times) and an integer amount.

Output: the minimum number of values needed to sum to amount; return -1 if impossible.

Constraints: explain state definition and initialization clearly; typical target O(len(values) * amount) time.

4) Sliding Window: find all anagram start indices

Input: strings s and p.

Output: all starting indices i such that s[i : i+len(p)] is a permutation of p.

Constraints: target O(|s|) time using a fixed-size window and character counts.

5) Array in-place: previous permutation with one swap

Input: an integer array a.

Output: the lexicographically largest array that is strictly smaller than a and can be obtained by at most one swap of two indices. If no such array exists, return a unchanged.

Constraints: in-place, O(n) or O(n log n); clearly discuss corner cases (duplicates, already smallest permutation, repeated values near the pivot).

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Salesforce•More Software Engineer•Salesforce Software Engineer•Salesforce Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.