Hamlet is a direct (if somewhat inverted) lift from Thomas Kyd's The Spanish Tragedie aka Hieronimo is Mad Again. In fact many, characterisations, tragic and comic scenes in Shakespeare's plays were lifts from other Tudor playwrights, Marlowe, Kyd and Lyly.