Strong memory chip earnings propelled tech giant Samsung Electronics to its best quarterly profit in more than 3 years.