Problem · Array
Assign Sequential Loan Identifiers
Learn this problemProblem statement
Assign a loan identifier to every transaction in an ordered batch.
Process transactionRefs from left to right. The transaction at index i receives identifier i + 1. Each row receives a distinct identifier; repeated reference strings are still separate transactions.
Return the assigned identifiers in the same order as the input transactions.
Function
assignLoanIds(transactionRefs: String[]) → int[]Examples
Example 1
transactionRefs = ["txn-a","txn-b","txn-c","txn-d"]return = [1,2,3,4]The transactions receive consecutive identifiers in input order.
Example 2
transactionRefs = ["retry","retry","settled"]return = [1,2,3]Each transaction row receives its own identifier, even when reference strings repeat.
Example 3
transactionRefs = ["only-transaction"]return = [1]The first transaction receives identifier 1.
Constraints
1 <= transactionRefs.length <= 100000.- Every transaction reference is a nonempty string of at most 100 characters.
- The returned identifiers fit in a signed 32-bit integer.