You can only revert the deletion of a folder, if it is the most recent action you have done in Photos. Then the keyboard shortcut ⌘Z will undo the deletion in Photos for Mac, or shaking the iPhone on Photos iOS.
But if you have used any other command after this, it will be too late. Then you will have to fall back on your backups.
To bring the albums back on a Mac, you may want to restore the most recent version your Photos Library from your last Time Machine backup you made, while the albums still have been there. Photos for Mac: Restore a Photos library from a Time Machine backup
To bring the albums back on an iPhone, you would have to restore the complete iPhone from the last backup you made: Restore your iPhone, iPad, or iPod touch from a backup - Apple Support
If you do not have a backup to use, you might be able to restore the albums - sometimes Photos will show deleted albums, when we search for the name of the album.
Type the name of a deleted album into the search field. Do you remember the exact names of the albums in the folder?