1. A method of encoding an input data into a codeword that satisfies a k constraint, the method comprising: using an encoder of a hard disk drive system: partitioning the input data into a plurality of data blocks comprising a first data block and a plurality of remaining data blocks; performing a first analysis of the plurality of data blocks for modifying each of the plurality of remaining data blocks that satisfy a first predetermined criterion; performing a second analysis of the plurality of data blocks after the first analysis for modifying each of the plurality of data blocks that satisfy a second predetermined criterion; converting each bit of the plurality of data blocks after the second analysis to produce the codeword in Non-Return-to-Zero (NRZ) format that satisfies the k constraint; and writing the codeword to a data recording layer.