Can anybody tell what logic is required in this i have tried everything but still it fails in one condition
another method that i have tried is