A new algorithm for dynamic network virtualization over flexible-grid networks is proposed. The algorithm, called Hamming-Fit, aims to map each request in a zone of the physical network resembling as much as possible the topology of the virtual network (sub-graph mapping). To do so, every possible node set (with as many nodes as the virtual network) of the physical topology is analyzed and its suitability evaluated using a metric analogous to the Hamming distance. In this way, a minimum usage of network resources is expected due to the use of 1-hop routes to establish the virtual links. The virtual link allocation also deals with the physical impairments of flexible grid networks by limiting the optical reach of the different optical signals and selectively adding guard bands when such optical reach must be surpassed. Simulation results show that Hamming-Fit exhibits a significant lower blocking than a previous proposal that uses exactly the same physical impairment model. The blocking improvement comes mainly from the fact that by performing a sub-graph mapping, shorter routes are used to map the virtual links. Thus, rejection due to the optical reach violation is minimized, which was the main drawback of the previous proposal.