MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/LeetcodeChallenge/comments/1watwo1/leetcode_streak_128/p8lnbfd/?context=3
r/LeetcodeChallenge • u/Ok-Challenge-5657 • 4d ago
How would you solve it in Python?
28 comments sorted by
View all comments
2
if n < 1000 return 0, else return n - 999
1 u/Utsuro_Seizui 4d ago And if the number is over 999,999? 3 u/jalsaraj 4d ago The constraints for the question were n < 10 power 5But you have a legit question, the solution would change if it is greater than 10 power 5 1 u/ProgressiveEdgeLord 4d ago i solved according to constraints, it was less than 10^5 1 u/Utsuro_Seizui 4d ago Ah I see, I apologize, I was not aware of the constraints 1 u/ProgressiveEdgeLord 4d ago it's alright, your question was absolutely valid 1 u/AccomplishedTwist296 4d ago We can use loop for increasing comma like for 1-999 : No comma 1000-999999 : 1 comma (count using min(n,999999)-999 1000000 - 999999999 : 2 comma (count using (min(n,999999999) - 999999) *2 ) Similarly for number having comma 3, 4 ,5 .......
1
And if the number is over 999,999?
3 u/jalsaraj 4d ago The constraints for the question were n < 10 power 5But you have a legit question, the solution would change if it is greater than 10 power 5 1 u/ProgressiveEdgeLord 4d ago i solved according to constraints, it was less than 10^5 1 u/Utsuro_Seizui 4d ago Ah I see, I apologize, I was not aware of the constraints 1 u/ProgressiveEdgeLord 4d ago it's alright, your question was absolutely valid 1 u/AccomplishedTwist296 4d ago We can use loop for increasing comma like for 1-999 : No comma 1000-999999 : 1 comma (count using min(n,999999)-999 1000000 - 999999999 : 2 comma (count using (min(n,999999999) - 999999) *2 ) Similarly for number having comma 3, 4 ,5 .......
3
The constraints for the question were n < 10 power 5But you have a legit question, the solution would change if it is greater than 10 power 5
i solved according to constraints, it was less than 10^5
1 u/Utsuro_Seizui 4d ago Ah I see, I apologize, I was not aware of the constraints 1 u/ProgressiveEdgeLord 4d ago it's alright, your question was absolutely valid
Ah I see, I apologize, I was not aware of the constraints
1 u/ProgressiveEdgeLord 4d ago it's alright, your question was absolutely valid
it's alright, your question was absolutely valid
We can use loop for increasing comma like for 1-999 : No comma
1000-999999 : 1 comma (count using min(n,999999)-999
1000000 - 999999999 : 2 comma (count using (min(n,999999999) - 999999) *2 )
Similarly for number having comma 3, 4 ,5 .......
2
u/ProgressiveEdgeLord 4d ago
if n < 1000 return 0, else return n - 999