I am a newbie enduro rider and also i love riding rough terrain uphills, my question is which set of cogs will be more efficient on my riding dicipline. 11-42t or 11-51t 11 speed cassette. Also, I am currently using 34t chainring.
A typical enduro bike spends a lot of time winching up steep but relatively smooth fire roads. That's the terrain where super-low gears come in most handy, because you can stay in the saddle and get the necessary power out of a high cadence rather than grinding torque. Besides comfort&endurance, staying in the saddle also has the advantage that you don't much need to worry about suspension bob or wheel spin. So if you expect to use the bike on such fire roads, I'd definitely go for the 11-51t.
If you use the bike more as a trail bike, i.e. shorter but more technical climbs, then there's not much point. On technical climbs, it helps to keep some momentum and have the saddle out of the way so you can better maneuver over obstacles and don't smash the pedals in some rock with every other stroke. So too low gears aren't much use, it's better to drop the saddle and power through it in a gear close to 1:1. If the climb is too long to sustain that power, then it's probably a case where pushing or carrying the bike is more efficient than struggling to pedal it out, though I personally also like that challenge – with a fast-engaging hub it's possible to ratchet up very steep and technical climbs in 1st gear, trials-style. Or if it's not too technical, you may also be able to still ride it in the saddle like on a fire road, thanks to full-sus.
On tarmac, there's also not much need for those gears – roads are seldom steep enough to require ratio lower than 0.8, even when riding in the saddle (though this of course also depends on the rider). Traction is not a problem either on tarmac, so you can better get out of the saddle than on gravel. I sometimes use my enduro bikes for longer tours with lots of baggage, and then slow spinning is again helpful, but OTOH I always miss the narrow steps and fast upper gears of a 2× drivetrain. Even my 1×12 \ 10-50t has rather too big steps for road riding, and 1×11 \ 11-51t is even worse. So on tarmac, a 11-42t would be a rather better choice. (Argument also applies for gravel touring.)
Finally, the 11-42t will probably shift smoother and more reliably, which is particularly useful for downhill passages. The smaller cassetter should also a bit lighter, improving rear suspension performance. If you expect to use the bike a lot in bike parks with lift/shuttle, then these are arguments for the 11-42t.
Equally efficient, in a practical sense cogs and chain have more or less the same efficiency. There are small differences for high end components.
The 11-51t cassette gives you a slightly lower low ratio of 0.67 while the 11-42 yields 0.8.
That lower ratio is great for grinding up steep hills but maybe you don’t need the extra gear. I personally wouldn’t be without my low 22/36 (0.61) ratio.
The technical issue is that your existing derailleur might not support the 51t cog / 40 tooth difference or the even 42 tooth top cog. Check the specs for the derailleur you have.
Even with 11 speeds, the gaps between the gears will be pretty big on 11-51, so it really should be based on whether you need such a low gear. If not, other riding will be more pleasant and efficient because you'll be able to ride at a more comfortable cadence more of the time.
The lowest gear you need depends on the terrain as well as your ability to handle the bike at low cadences/high efforts on (hopefully not too common) occasions.