NEW YORK — Back in May, in the aftermath of early losses for both at the French Open, good friends Serena Williams and Caroline Wozniacki, who was about a week removed from the end of her engagement to golf star Rory McIlroy, flew from Paris to Miami and hung out.

They went to the beach and to an NBA playoff game — and they posted photos of the good times on social media.

“Serena is a fun girl. She’s so nice to hang out with. Always makes me laugh and makes everyone around her laugh,” Wozniacki said. “Definitely a very inspiring person to be around.”

A few months later, Williams and Wozniacki are back at the top of their games and back together, facing one another Sunday for the U.S. Open title.

So when they were palling around in Florida, did they discuss the idea of turning their seasons around?

“No. Not at all. Not even once,” said Williams, who is bidding for Grand Slam trophy No. 18 and U.S. Open title No. 6, including three in a row. “We never talk tennis so much, since we spend so much of our life on the court. Same with me and Venus. Last thing on our minds is tennis. If anything, it’s to not think about a forehand or a backhand.”

They did chat right before play began at Flushing Meadows, noting that the draw placed the top-seeded Williams and 10th-seeded Wozniacki on opposite sides of the bracket.

“It was like, ‘Oh, it would be much better to play each other in the final than earlier on.’ I was just glad we weren’t on the same side of the draw,” Williams said. “Of course, we were like, ‘That would be great if we could see each other in the final,’ because we both, you know, hadn’t had the greatest Grand Slam year.”

That is true. Williams has not dropped a set the past two weeks while stretching her U.S. Open winning streak to 20 matches. But she lost in the fourth round at the Australian Open, the second at the French Open and the third at Wimbledon.

Wozniacki, whose reputation as a counter-puncher is in complete contrast to Williams’ power-based style, exited in the third round at the Australian Open and Wimbledon, and the first at the French Open.

Here’s a key difference: Williams is not used to leaving such tournaments so early. She has reached at least one Grand Slam final in each of the past eight seasons, winning 10 major titles in that span. Wozniacki will be participating in only the second major final of her career; she lost to Kim Clijsters at the 2009 U.S. Open.

“I have definitely learned a lot in those years,” said Wozniacki, whose high-profile relationship with McIlroy ended while the wedding invitations were in the mail. “I would love to ... have a Grand Slam under my belt. It would definitely have the media stop talking about my lack of a Grand Slam, so that would be nice.”

No matter how close they’ve become, neither Williams, who turns 33 this month, nor Wozniacki, a 24-year-old from Denmark, expects their off-court buddy-buddy status to have any effect on what happens in Arthur Ashe Stadium.

“The friendship, while we are on court, is put aside. We are both competitors,” said Wozniacki, who has lost eight of nine previous meetings against Williams. “After the match, one of us is going to congratulate the other and we’re going to be friends again. It’s fine.”

Williams, of course, has plenty of experience forgetting her feelings about an opponent during a match: She has faced her sister 25 times, including in eight Grand Slam finals.

“If I can play Venus, I can play anybody. I grew up with Venus. We actually lived together going on 33 years,” Williams said with a laugh, “which is kind of sad.”