Efficient algorithms for reconciling gene trees and species networks via duplication and loss events