update result index based on problem requirement