Around 8 p.m. Wednesday, a man paused at a corner in Ozone Park, Queens, and scrawled letters and symbols on a stop sign:

$Killzz

I will

BK

At the bottom he drew a smiley face, one eye winking.

A moment later, two detectives stepped up and called the man by name: Daniel St. Hubert. He was placed under arrest, and the police now believe he committed a string of shocking crimes between Friday and Wednesday morning. He was carrying a brown-handled knife in his waistband and a cellphone in his pocket, said Stephen Davis, the Police Department’s chief spokesman.

The words on that stop sign — since removed — were the last traces that the police found of Mr. St. Hubert, 27, as they tracked him from the scene of one slashing to the next: an 18-year-old woman, killed in the East New York section of Brooklyn on Friday night as she was going to meet her friends after band practice. A short distance away on Sunday afternoon, two children set upon as they rode the elevator on their way to get a treat — a 6-year-old boy knifed to death and a 7-year-old girl slashed within an inch of her life. And near dawn Wednesday, a 53-year-old homeless man on a subway platform in the Chelsea section of Manhattan, stabbed and slashed as he slept on a bench.

As of late Thursday, Mr. St. Hubert had been charged with the attacks on the children.

At nearly every step in three boroughs, the authorities said, Mr. St. Hubert left digital and physical evidence, all of which began to be unlocked midday Wednesday in an eight-hour avalanche of revelations. Around noon, a laboratory report on the knife used in the Sunday elevator attack came back with Mr. St. Hubert’s DNA profile, which was in a state database.

It was the first time detectives had a name for their suspect. They obtained the number of a cellphone that he was using, and tracked its beacon signal as he moved around the city Wednesday afternoon and evening. Early on, it showed that he was on Queens Boulevard, but the signal disappeared.