https://ide.codingblocks.com/s/188862
1- code is not running prperly for last case .
2- time compl is o(tnlog(n)) can u improve it
3- not able to handle those cases when so such no found whose sum is not equal to given no ex 1000
Vivek and factors
Hi @sgdon142,
You can simply apply Brute force(using sieve), calculate sum of factors for numbers till 1e5 and check whether any number has this sum present in the array otherwise print “-1”.
For reference, use this: https://ide.codingblocks.com/s/188871
Hope it helps.
it also shows wrong ans.
Hi @sgdon142
There was an error in placement of brackets. Now it is corrected: https://ide.codingblocks.com/s/189070
Hope it helps.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.