FastPrepPhoto Album
Problems/Photo Album

Photo Album

Honda R&D logoHonda R&D● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Honda R&D online assessment. Our version is about 90% the same as the shared Photo Album question. The original interview statement and limits were not given. The number limits and the examples are our choices.

Special thanks: 🌷 A special thank you to a lovely, amazing fren who shared that this question appeared again on October 17, 2026! ( ˘͈ ᵕ ˘͈♡) 🩷

An album starts empty. You are given two integer arrays, index and identity, each of length n.

Process the photos in input order. At step i, insert the photo with ID identity[i] at zero-based position index[i] in the current album. Shift every photo at that position or farther right one position to the right.

  • index[i] = 0 inserts at the beginning.
  • index[i] = i appends after all photos already inserted.
  • Photo IDs are values, not insertion positions. Repeated IDs are allowed and represent separate photo entries.

Return the final left-to-right sequence of photo IDs after all n insertions.

Function

photoAlbum(index: int[], identity: int[]) → int[]

Examples

Example 1

index = [0,1,1,0]identity = [20,30,40,10]return = [10,20,40,30]

The album changes from [] to [20], then [20,30], then [20,40,30], and finally [10,20,40,30].

Example 2

index = [0,0,0,0]identity = [7,7,2,9]return = [9,2,7,7]

Every photo is inserted at the front, reversing the insertion order. Both entries whose ID is 7 remain in the album.

Example 3

index = [0,1,2]identity = [5,3,2]return = [5,3,2]

Each photo is appended, so the final order equals the input ID order.

Constraints

  • 1 <= n <= 2 * 10^5.
  • index.length = identity.length = n.
  • 0 <= index[i] <= i for every 0 <= i < n.
  • 0 <= identity[i] <= 10^9. IDs need not be distinct.

Similar questions at other companies

  • Rolling MetricsAkuna Capital · OAAkuna Capital interview questions
  • Minimum Bridge TurnbacksBNSF Railway · OABNSF Railway interview questions
  • Count Smaller Prior ElementsTata Consultancy Services · OATata Consultancy Services interview questions
  • Horizontal Pod AutoscalerSnowflake · OASnowflake interview questions
  • Horizontal Pod AutoscalerRubrik · OARubrik interview questions
  • Adjust Prices 🍱DoorDash · OADoorDash interview questions
  • Photo AlbumFactSet · OAFactSet interview questions
  • Maximum Profit from an Increasing Price TripletOdoo · OAOdoo interview questions
  • Count Decreasing TripletsAirbnb · OAAirbnb interview questions
  • Maximize Shipment Order by Sorting One WindowAmazon · OA
See Honda R&D hiring insights
Saved
class Solution {
    public int[] photoAlbum(int[] index, int[] identity) {
        // Return the final left-to-right order of the photo IDs.
    }
}
Checking account…