FastPrepPhoto Album
Problems/Photo Album

Photo Album

FactSet logoFactSet● MediumOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

There is a collection of photos to place into an empty photo album, one at a time by order of importance. Each time a photo is inserted, all subsequent photos are shifted toward the right by one position. Given the id's of the photos and the positions where each should be placed, find out the sequence of the photos in the album after all photos have been inserted.

Function

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

Complete the function photoAlbum in the editor.

photoAlbum has the following parameter(s):

  1. int index[n]: the positions where the photos are to be inserted
  2. int identity[n]: the photograph id numbers

Returns int[n]: the sequence of identity values after all are inserted

Input Format For Custom Testing

The first line contains an integer, n, the number of elements in the array index. Each line i of the n subsequent lines (where 0 ≤ i < n) contains an integer, index[i]. The next line contains an integer, n, the number of elements in the array identity. Each line i of the n subsequent lines (where 0 ≤ i < n) contains an integer, identity[i].

Examples

Example 1

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

The output array goes through the following steps: [0] -> [0, 1] -> [0, 2, 1].

Example 2

index = [0, 0]identity = [0, 1]return = [1, 0]

The output array goes through the following steps: [0] -> [1, 0].

Example 3

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

The output array goes through the following steps: [0] -> [1, 0] -> [2, 0, 1].

Constraints

  • 1 ≤ n ≤ 2 x 105
  • 0 ≤ index[i], identity[i] < n (0 ≤ i < n)

More FactSet interview questions

  • Largest Square of 1'sOA · Seen Sep 2024
  • Last Stone WeightOA · Seen Sep 2024

Similar questions at other companies

  • Photo AlbumHonda R&D · OA
  • 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
  • Maximum Profit from an Increasing Price TripletOdoo · OAOdoo interview questions
  • Count Decreasing TripletsAirbnb · OAAirbnb interview questions
  • Maximize Shipment Order by Sorting One WindowAmazon · OA
All FactSet interview questionsSee FactSet hiring insights
Saved
class Solution {
    public int[] photoAlbum(int[] index, int[] identity) {
      // write your code here
    }

}
Checking account…