Sacramento Kings guard Bogdan Bogdanovic, right, is double-teamed by New...

Sacramento Kings guard Bogdan Bogdanovic, right, is double-teamed by New York Knicks' Tim Hardaway Jr., left, and Michael Beasley during the first half of an NBA basketball game, Sunday, March 4, 2018, in Sacramento, Calif. Credit: AP / Rich Pedroncelli

SACRAMENTO, Calif. — For three quarters, the Knicks played like a team that didn’t care about winning. They were fortunate that their opponent seemed to have that attitude for most of the fourth.

The Knicks erased a 19-point deficit in the last nine minutes but still found a way to lose Sunday night. Skal Labissiere drilled a three-pointer over Kyle O’Quinn with 1.6 seconds left to give the Kings a 102-99 victory. Trey Burke’s desperation heave from behind midcourt hit the side of the rim at the buzzer as the Knicks fell for the 12th time in their last 13 games.

This was an extremely embarrassing performance and loss. The Kings (20-44) are going all in on tanking for a better draft pick. They started three rookies and a second-year player, and veteran Zach Randolph was a healthy scratch. Yet the Knicks, who reject the idea of tanking, didn’t show up until 39 minutes into the game.

After the Knicks (24-40) lost by 23 points to the Clippers on Friday night, Jeff Hornacek challenged his players’ toughness, smarts and pride. They didn’t respond the way he had hoped, though.

“We’re floating through things,” Hornacek said. “OK, we’re not in the playoffs, you still got to play with a desperation every time you go out on that court. The final quarter, that’s how you’re supposed to play all the time. It’s disappointing that they think they can just show up and play the game. You have to have a different attitude and play like you did in the fourth quarter.’’

Tim Hardaway Jr. had 24 points, Enes Kanter added 14 points and 16 rebounds, and O’Quinn also scored 14. Starting point guard Emmanuel Mudiay shot 0-for-6 and was scoreless in 19 minutes. Bogdan Bogdanovic’s 22 points led the Kings.

Trailing 92-73 with 8:53 left, the Knicks produced a 24-5 run. Instead of clearing his bench and using the younger players, Hornacek used his veterans and went for the win.

The Knicks tied the score at 97 on Michael Beasley’s basket with 1:09 left and had a chance to take the lead on the next possession, but Vince Carter slapped the ball away from Beasley and it went out of bounds off the Knicks with 33.7 seconds left. Bogdanovic’s pull-up jumper put the Kings up 99-97 with 29 seconds to go — only their second made basket in six minutes.

O’Quinn was fouled while going up for a dunk and sank both free throws to tie it with 16.6 seconds left. The Knicks had a foul to give and committed it with 5.3 seconds to play. Then Bogdanovic inbounded to Labissiere and O’Quinn backed up a little, giving Labissiere a little room. He had made only 10 three-pointers all season (in 29 attempts), but No. 11 was a game-winner.

After Labissiere’s basket, Randolph ran on the court to celebrate with him while the ball was in play and was assessed a technical foul. Courtney Lee missed the foul shot and Burke missed his desperation three-point heave.

“You just got to hold the rope, don’t let it go, stay together,” Hardaway said. “A lot of good is going to come out of this. As long as we compete like we did in the fourth quarter throughout the whole entire game, we’ll give ourselves a chance.”

The days are winding down on the Knicks’ season and maybe Hornacek’s time as their coach, but his message before this game was to play with pride. He wondered where it was against the Clippers, and it took a long time to show some against the Kings.

The Knicks are careening toward a fifth straight year of missing the playoffs and a fourth straight season with at least 50 losses, but Hornacek said they should be playing for something and not just going through the motions. He doesn’t believe it should be hard for the players to remain engaged despite the current state of affairs. It’s their job.

From the beginning of what was considered a rebuilding and developmental season, general manager Scott Perry said he wanted to see the Knicks compete every night. Clearly, they haven’t.

“I think some of the guys think they’re playing hard,” Hornacek said. “I’m sure these guys are saying ‘I’m playing as hard as I can.’ But there’s a different level between playing hard and playing with that desperation that ‘I’m going to do anything it takes to win.’ That’s an internal thing.

“If you want to be in this league and be great, then that’s what you have to do and not just do it when you’re down by 15. You have to do it from the start. That’s a mentality that somehow we got to try to get into some of these guys.”

Newsday LogoSUBSCRIBEUnlimited Digital AccessOnly 25¢for 5 months
ACT NOWSALE ENDS SOON | CANCEL ANYTIME