The PC maker’s earnings grew faster than expected, as Lenovo began to reap benefits from its bets on artificial intelligence.