Apple is within striking distance of overtaking Nvidia as the world's most valuable company, a milestone that would reshuffle the ranks of tech heavyweights as investors reassess the outlook for AI.