Greedy reconstruction algorithm for the identification of spin distribution