Alright, lets get started.
Suppose number of books Jim have = x
Sam has twice as many books as Jim. So,
Number of books Sam have = 2x
If Sam gives 12 books to Jim, they will have the same number of books.
When Sam gives 12 books, his remaining books will be 
When Jim gets 12 books from Sam, his books will be 
And as per given question, they both now have equal books, so

Adding 12 in both sides


Subtracting x from both sides


It means Jim has number of books = 24
So, Sam has numberof books = 
So, they have number of books together =
: Answer
Hope it will help :)