added remove duplicates and reverse k elements