FastPrepCalculate Difference Value 🍧
Problems/Calculate Difference Value 🍧

Calculate Difference Value 🍧

DoorDash logoDoorDash● MediumFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

As an assignment, students at HackerLand High School are to find a subsequence using two strings by performing the below-mentioned operation. Given two strings firstString of length n and secondString of length m, the goal is to make secondString a subsequence of firstString by applying the operation any number of times.

In one operation, any single character can be removed from the secondString. The goal is to find the minimum possible difference value which is calculated as: | maximum index of all the characters removed from the string secondString | - | minimum index of all the characters removed from the string secondString | + 1. Removing a character from secondString does not affect the indices of the other characters and an empty string is always a subsequence of firstString.

Note: A subsequence of a string is a new string formed deleting some (can be none) of the characters from a string without changing the relative positions of the remaining characters. "ace" is a subsequence of "abcde" but "aec" is not.

Function

findDifferenceValue(firstString: String, secondString: String) → int

Complete the function findDifferenceValue in the editor.

Examples

Example 1

firstString = "HACKERRANK"secondString = "HACKERMAN"return = 1

Remove the character at index 7 to change secondString to "HACKERAN", a subsequence of firstString. The difference value is 7 - 7 + 1 = 1. Return 1.

Constraints

  • Unknown for now 🍰

More DoorDash interview questions

  • Random Dasher Set OperationsONSITE INTERVIEW · Seen Nov 2026
  • Customer Bootstrap APIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dasher Pay with Store Waits and Peak HoursPHONE SCREEN · Seen Nov 2026
  • Team FormationOA · Seen Oct 2026
  • Simulate an Idempotent Refund Service FlowONSITE INTERVIEW · Seen Sep 2026
  • Dasher Active TimePHONE SCREEN · Seen Sep 2026
  • First Unique ID in a StreamONSITE INTERVIEW · Seen Aug 2026
  • Minimum Parenthesis Removals and Their IndicesONSITE INTERVIEW · Seen Aug 2026
  • Minimum Processing Speed with Multiple RidersONSITE INTERVIEW · Seen Aug 2026
  • Minimum Single-Rider Processing SpeedONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • K Smallest SubstringAkuna Capital · OAAkuna Capital interview questions
  • Shortest SubstringRippling · OARippling interview questions
  • Shortest Deletion for Distinct CharactersOracle · ONSITE INTERVIEWOracle interview questions
  • Shortest Deletion for a Distinct RemainderGoogle · PHONE SCREENGoogle interview questions
  • Perfect SubstringAXQ Capital · OA
  • Count Subarrays With Product Equal to KSalesforce · OASalesforce interview questions
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Maximum Valid Substring FrequencyMicrosoft · OAMicrosoft interview questions
  • String CompressionAbridge · OAAbridge interview questions
  • Same Substring Within BudgetJP Morgan Chase · OAJP Morgan Chase interview questions

DoorDash interview experiences

  • DoorDash SWE Onsite: Donation System Design: 1 Experience
  • DoorDash SWE Phone Screen: Bootstrap API in Java: 1 Experience
  • DoorDash SWE Virtual Onsite: 1 Experience
  • DoorDash SWE Phone Screen: Bootstrap API Parsing: 1 Experience
  • DoorDash Senior SWE Onsite Interview Experience: 1 Experience
  • DoorDash AI CodeCraft Interview: 8 Experiences
All DoorDash interview questionsSee DoorDash hiring insights
Saved
class Solution {
    public int findDifferenceValue(String firstString, String secondString) {
        // write your code here
    }

}
Checking account…