The S&P 500 and Nasdaq have recently reached fresh all-time highs, and it might seem like attractive investment opportunities are becoming rare. However, a look inside Warren Buffett-led conglomerate Berkshire Hathaway's stock portfolio might reveal some of the most interesting opportunities for long-term investors right now.

With that in mind, here are three of the stocks in Berkshire's portfolio that all look attractive right now and have lots of room to grow and produce market-beating returns in the years to come.

A great environment for homebuilders

If you rewind the clocks to the start of 2023, few investing experts were giving homebuilders a fighting chance. But they were wrong. In fact, with existing home inventories at a generational low and homebuilders able to offer excellent mortgage incentives, it created an extremely strong environment for new-home sales.

Berkshire bought shares of three homebuilders in 2023, and the most exciting one may be NVR (NVR -1.01%). If you aren't familiar with the company, NVR uses a land-light model.

Unlike most builders, the company doesn't buy large quantities of land. Instead, it buys purchase options on building lots and doesn't buy them until it has a home under contract. This frees up more capital to grow the business.

In the fourth quarter, the company reported an impressive 25% year-over-year increase in new orders and a 12% increase in its backlog. Homebuilding revenue declined slightly year over year but not nearly by as much as experts were projecting at the beginning of the year.

With this amount of order growth, the future looks strong. Even though shares are up 67% year over year, NVR's valuation of just 16x forward earnings in a still-strong environment for new-home sales looks extremely reasonable.

A surprising leader in online banking

If someone had told you 20 years ago that General Motors' financial arm would become one of the top online banks in the U.S., you might not have believed them. But Ally Financial (ALLY 0.41%), which was spun off from GM in the wake of the financial crisis, has done just that.

Because of the company's roots, it shouldn't be a surprise that the biggest part of Ally's business is auto lending. But there's so much more to this company. It has an excellent consumer deposit platform that has $155 billion in total deposits, a variety of other loan types, a brokerage platform, and much more.

Berkshire owns just under 10% of Ally, and it isn't hard to see why. This is a highly profitable business. Its average auto loan in 2023 was originated with a 10.7% yield.

The bank's average cost of funding (mostly deposits) is 4.35%, even with a reasonable amount of loan defaults, which leaves a pretty solid margin. Plus, that cost of funding could come down significantly if interest rates start to fall this year, as is widely expected.

For 2023, Ally's 3.35% net interest margin was one of the best in banking. With the stock trading for 12x forward earnings, it could be a bargain.

Could a big merger take this financial stock to the next level

One of the more recent financial stocks added to Berkshire's portfolio, Capital One (COF 0.16%) could be an interesting opportunity for long-term investors, especially with its pending acquisition of Discover (DFS 1.62%).

The deal will combine two of the largest credit card issuers in the United States, which will create some major cost advantages. Capital One expects $2.7 billion in annual synergies from the deal by 2027, and its banking infrastructure could be an asset to Discover's banking products, which currently operate entirely online.

However, the real potential could be Capital One owning one of the four major payment networks. Discover is a distant fourth right now but could have massive growth potential under Capital One. Not only could the bank eventually move much of its own debit and credit card products to Discover's network, but it also can afford to invest more heavily in growing the network than Discover could on its own.

Even though they're near a 52-week high, Capital One shares are trading for an 8% discount to their book value and just 10x forward earnings. With the possibilities created by the Discover acquisition, Capital One is worthy of a closer look right now.

Three solid businesses

These are all rock-solid companies that are among the leaders in their respective industries (homebuilding, online banking, credit card lending), and all three have lots of room to grow. These stocks could be rather volatile in the short term, but investors who buy them now and hold on for years could be very glad they did.