Simple solution without the need to mark completed
Simply keep swapping the current value with it\'s correct position until the array is in order:\n\n\nans = 1\nfor i in range(len(nums)):\n    cnt = 1\n    while
Simply keep swapping the current value with it\'s correct position until the array is in order:\n\n```\nans = 1\nfor i in range(len(nums)):\n    cnt = 1\n    while nums[i] != i:\n        nums[nums[i]], nums[i] = nums[i], nums[nums[i]]\n        cnt += 1\n    ans = max(ans, cnt)\n```\n\n[5, 4, 0, 3, 1, 6, 2]\n[6, 4, 0, 3, 1, 5, 2]\n[2, 4, 0, 3, 1, 5, 6]\n[0, 4, 2, 3, 1, 5, 6]\n[0, 1, 2, 3, 4, 5, 6]
[]