The simple answer
According to the DMG p.83, each encounter is discrete even if they are multi-part encounters:
For such encounters, treat each discrete part or wave as a separate encounter for the purpose of determining its difficulty.
So:
Easy + Medium = Easy + Medium
Easy + Easy + Easy = Easy + Easy + Easy
Medium + Medium = Medium + Medium
The complicated answer
D&D 5e encounters are a resource management game: that is, the players must use/conserve their limited resources (hp, spell slots, limited use abilities like channel divinity and bardic inspiration etc.) with limited information about the strength of the enemies in this encounter and without knowing how many more encounters there will be (and the strength of each of those) before they can replenish their resources through short or long rests, restocking on healing potions or being able to cast Cure Wounds etc. between encounters.
This is covered (without specifically calling it out as a resource management issue) in the section on "The Adventuring Day" on p.84 of the DMG. That section sets an XP budget between long rests (when almost all resources fully reset1) and tells you that there should be 2 short rests between long rests.
Now, the DMG keeps all of this stuff denominated in XP which complicates the hell out of everything, so I offer a simpler solution: denominate things in terms of the Medium encounter and decide that you want half of your XP to come from Medium encounters, one quarter from Easy and one quarter from Hard and be very, very careful with Deadly2.
If you do this, at all experience levels3 there will be 3-4 Easy, 3 Medium and 1 Hard encounter in each daily budget. Dividing this between your rests gives:
- Easy, Medium, Short Rest,
- Easy, Medium, Short Rest,
- Medium, Hard, Long Rest
- with possibly 1 more easy thrown in somewhere.
which gives a nice pacing to the day, sort of building in tempo to the climactic battle.
A gap between these encounters is not really necessary. It can help if, for example, characters need to be healed but it can also hinder if, for example, long running effects (bardic inspiration, long-duration spells, barbarian rage etc.) expire rather than rolling into the next encounter
1 The only resource that doesn't fully reset with a long rest is hit dice you can spend during short rests - you only get half your level of these back. Oh, and any healing potions etc. that you need to go back to town for.
2 Deadly encounters can be ... deadly and should therefore be used with care and caution. When you use them they should be early in the day (not later than the third encounter) so that the players have a lot of resources to throw at a problem which can definitely kill them if they hold back. A party (once out of the very low levels) can deal with CR encounters 4 or 5 higher than their level if they have near full resources and know that its OK to use them profligately.
3 OK, the maths doesn't work out exactly: this is not an exact science but there is an underlying pattern in the figures and the difference probably arises from rounding off.