Brooklyn, N.Y. • Huddled with his teammates during a timeout, a frustrated Yoeli Childs threw down his towel as if to say enough was enough. A few minutes later, the Cougars’ standout sophomore was throwing down a two-handed jam to cap a game-winning rally Saturday.

Childs’ dunk with 4.1 seconds to play gave BYU a 68-66 win over UMass on the second day of the Barclays Center Classic.

“Me and some guys were just trying to get after each other and get some energy going,” Childs said after scoring 19 points and grabbing 11 rebounds in the win. “I think we all just really trusted each other … just to come out and make the plays we make every day in practice.”

BYU put the ball in the hands of point guard Jahshire Hardnett (10 points, 2 assists) to make something happen with the game on the line. Hardnett dribbled the length of the court, used a screen from Payton Dastrup at the top of the key and found Childs in the paint after a UMass defender stepped up to stop the dribble penetration.

“It was just an opening in the lane,” Hardnett said. “His man stepped up … so I dumped it off.”

Childs’ dunk rocked the rim, had the Cougars leaping out of their seats on the bench and improved BYU to 4-2 on the season.

Coming off a double-digit defeat to No. 25 Alabama on Friday, BYU started fast Saturday with Childs scoring the game’s first nine points. Things started to fall apart after that, however, causing BYU coach Dave Rose to question his team’s effort.

“We were playing really hard when things were going good to start the game and then things start going the other way,” Rose said. “I don’t think that’s acceptable. You can control your effort no matter if you’re playing well or executing well.”

When UMass’ Carl Pierre drained a 3-pointer with 4:44 to play, the Cougars trailed by 10 points. That’s when BYU dug deep to put together a game-saving 11-0 run.

“Those are the things that are really important early in the year when you’re trying to build a team. When you get in these close games, especially on the road, can you find a way to win?” Rose said. “We did that other night at Princeton and then here. When you’re behind the whole time and find a way to finish and win, hopefully that helps the group’s confidence. That’s what we’re looking for right now.”

UMass was led by 16 points and eight rebounds from center Rashaan Holloway. The Cougars managed to slow down the Minutemen’s leading scorer, guard Luwane Pipkins, who finished 1 for 12 from the field.

BYU got 18 points from guard Elijah Bryant, who bounced back from a poor shooting effort against Alabama. Hardnett’s 10 points were a season high. And Childs continued his impressive start to the season, recording a double-double on back-to-back nights.

The Cougars only shot 36.4 percent from the field but managed to grind out a win by out-rebounding UMass 43-31. The Cougars pulled down an impressive 19 offensive boards in the process.

“Coach kind of got on us at halftime about the effort we had in the first half,” Childs said. “It was unacceptable in the first half. I think we did a good job of coming back out and played hard. That’s what it was all about.”

BYU 68, UMASS 66

• BYU sophomore Yoeli Childs scores the game’s first nine points and provides the final two — a game-winning dunk — with 4.1 seconds to play.

• The Cougars grab 19 offensive rebounds, record 10 steals and block six shots.

• UMass’ Luwane Pipkins, who was averaging 21.4 points per game, is held to nine points and only shoots 1 of 12 from the floor.