FastPrepLongest Sorted Adjacent-Difference Subsequence
Problems/Longest Sorted Adjacent-Difference Subsequence

Longest Sorted Adjacent-Difference Subsequence

Atlassian logoAtlassian● MediumINTERNFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Atlassian online assessment for interns and full-time roles. Our version follows the whole prompt as shown in the report.

Select a subsequence, then sort its values. In the sorted result, every adjacent difference must be either 0 or 1. Return the maximum possible subsequence length.

Function

longestAdjacentDifferenceSubsequence(arr: int[]) → int

Examples

Example 1

arr = [4,2,1,3,2,3]return = 6

After sorting all values become [1,2,2,3,3,4], whose adjacent differences are 0 or 1.

Constraints

  • 1 <= arr.length <= 100000
  • Values fit in a signed 32-bit integer.

More Atlassian Online Assessment questions

  • Planning ProductionOA · Seen Feb 2025
  • K-Means ClusteringOA · Seen Feb 2025
  • Minimum Sorted Erasure OperationsOA · Seen Jun 2024
  • Count Analogous ArraysOA · Seen Mar 2024
  • Get Maximum ScoreOA · Seen Mar 2024
  • Better Compression 🦀OA · Seen Mar 2024
  • Romanizer 🐡OA · Seen Mar 2024
  • Flower Bouquets 💐OA · Seen Mar 2024
  • Binary Search Tree IteratorOA · Seen Nov 2023
  • Binary Tree Level Order TraversalOA · Seen Nov 2023

Similar questions at other companies

  • API Rate Limit Violation DetectionTekion · OATekion interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Minimum Distinct Prefix CostChubb · OAChubb interview questions
  • Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
  • Convert Sparse Records to a Filled TableNetflix · OANetflix interview questions
  • Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
  • Aggregate Paginated Project Run RecordsReplit · OA
  • Efficient TeamsExpedia · OAExpedia interview questions

Atlassian interview experiences

  • Atlassian MLE Phone Screen: Model Deployment Design: 1 Experience
  • Atlassian Coding Screens and Karat: 3 Experiences (Part 2 of 2)
  • Atlassian Full Stack Interviews: 11 Experiences (Part 1 of 2)
All Atlassian interview questionsSee Atlassian hiring insights
Saved
class Solution {
    public int longestAdjacentDifferenceSubsequence(int[] arr) {
      // Write your code here.
    }

}
Checking account…