Suppose i have an array which has books id, For Example [1,42,34,56,21,8,88,32]
all distinct, and i have an array of book objects example :
[
{
BookId: 34, BookName: Foo1
},
{
BookId: 56, BookName: Bar1
},
{
BookId: 1, BookName: Foo2
},
.....
]
Books are not in same order as book ids array, although size of both arrays is equal, i want a resulting array of books, in-order with book id array
.
I can use nested loops, but that would be m×n complexity.
So basically i wanna perform something like SQL
join.
Is it possible to reduce the complexity?