Not a complete answer, but some thoughts that wouldn't fit in a comment:
Interestingly, you need "PITI reserves" to get a mortgage in the first place, and, typically (good news) 50% of your 401K amount count "as PITI reserves" so double win up to that.
"At some places" you can even take a loan out against a portion of your 401K and use that as the mortgage down payment.
So you may be able to "do both" to some extent. At very worst you could actually make an "early withdrawal" from your 401K, pay the (various) penalties at tax time, and still come out on top thanks to your employer's matching contribution. Not the perfect option but available.
So all of these seem to favor investing into the 401K but it's still a personal decision, I mean if you can save up aggressively for 6 months and get a house it might be worth it if houses are appreciating rapidly in your area, still depends. Even then you'd still "leave some money on the table" but it's possible.
I would recommend owning a house over paying rent as the rents go up every year but mortgages don't. The only risk is if you need to soon move (esp. if house prices have dropped in the meantime), but in general my recommendation (if you have no immediate plans to move) would be pull the trigger and buy, it's almost always better than renting over the long term, though initially it might be slightly more expensive (monthly cost), at least the money is eventually going toward equity you'll be building up. If you're in the US you can get FHA loans for 3.5% down, or conventional for 5% down. These have "mortgage insurance" added but for the conventional once you've "paid off" (or appreciated) 20% LTV total then you can drop the mortgage insurance. Long term it is a nice win.