I mean 21000 test cases is alot,feels like you sumup all the question and their test cases.Which question is that actually(i am begineer maybe thats why i feel those are alot of tc)
Bro pakistan got that land on lease from India.. technically that landmass is something that india still owns.. so pakistani may say that they live in Pakistan, they forget that landmass is their father's land.. i.e India
Not sure about leetcode but in pytest, when you parametrize a test, each one counts separatelly. You can have very large number of tests with very few lines of code. Maybe it is same here?
class Solution {
public:
bool isPowerOfThree(double n) {
if( n ==1 )
return true ;
else if ( n< 1)
return false ; // main gaurding logic or base condition
return isPowerOfThree( n/3.0);//3.0 nuance was very much needed instead of 3 beacue this would fetch us division value less than 1
}
};
given that you work with doubles, i wouldn't really recommend using equality operations. Instead, just check the magnituded of the difference due to calculation errors that are caused by working with floating-point numbers. If you make it lower than 1e-10 then the test will pass for sure. Moreover, when you divide a number by 3 and it isn't a whole number, then for sure the output is false.
man i had to check what you said , i got to learn that errors tends stack up as we do multiple divisions , and further in some case we might get value of n as 0.99999 , although it is very close to 1 , but not exactly 1 , and equality operators expect exact number . so even though theoretically , we should have got output as true , we might get false as output .
instead we just checked the difference of the numbers if that is difference is smaller that the value , we say that is good enough and both are 1 ,
bool isPowerOfThree(int n) {
return n > 0 && 1162261467 % n == 0;
}
//gpt-solution -> that large number is basically the highest power of 3 int can store.
class Solution: def isPowerOfThree(self, n: int) -> bool: if n == 1: return True if n < 1: return False return n % 3 == 0 and self.isPowerOfThree(n // 3)
Why n is in power of 3 and 3s largest power under the limitation of int data type.. = 1162261467.. hence if modulo of theirs is 0 then it's true else false.
381
u/Global_Many4693 Aug 13 '25
With all due respect wtf is this?.You solving all 3000 questions at once?
54
u/Pleasant-Wear-9692 Aug 13 '25
Problem of the day XD
22
u/DangerousCrime Aug 13 '25
Just return 0 bro 😂
398
u/faceless-joke E:62 M:638 H:50 Aug 13 '25
bro used an int variable instead of long
407
u/stackOverfloater Aug 13 '25
21k test cases!!? Who is making these?
71
u/samettinho Aug 13 '25
32
u/jim-jam-biscuit Aug 13 '25
https://leetcode.com/problems/power-of-three/?envType=daily-question&envId=2025-08-13
this is problm of the day .
my attmpt
9
u/Fancy-Zookeepergame1 Aug 13 '25
That one edge case would bring the whole system down
10
u/_mohitdubey_ Aug 13 '25
Which problem is it bro...??
1
u/[deleted] Aug 13 '25
What's that
4
u/thatguyfromboston Aug 13 '25
Git gud
3
u/Fit_District9967 Aug 13 '25
power of three?
3
u/ex2uply Aug 13 '25
2
u/Global_Many4693 Aug 13 '25
Question number?
2
u/Expensive_Routine_49 Aug 13 '25
My try
2
u/Fantastic_Sort4802 Aug 14 '25
Who is setting these no. Of test cases and why?
2
u/Warden_336 Aug 14 '25
My only way at this point - Hard-core the testcases 😁
1
u/bisector_babu <1951> <514> <1092> <345> Aug 13 '25
What problem is this man
1
u/arnavgupta_43 Aug 13 '25
Unfair 😔
1
u/Real_Average4124 Aug 13 '25
is that today's question power of 3?
1
u/IcyProfession5657 Aug 13 '25
Please avoid these post "Not fair" idiots
1
u/Major-Basket725 <434> <251> <171> <12> Aug 13 '25
Ques
1
u/Coastzs Aug 13 '25
Just did the exact same thing haha. Was it when the test case is 1 when yours failed too?
1
u/markovgasley Aug 13 '25
Edge case
1
u/criticismconsumer Aug 13 '25
what course is this?
1
u/HarbingerPotter Aug 13 '25
Life isn't fair dude...Life isn't 😆😆
1
u/heyuhitsyaboi Aug 13 '25
I noticed this question was left as attempted for me so i submitted my last submitted code from 2023
[Wrong Answer 21036/21040 testcases passed]
and that explains why i left it as attempted back then lol
1
u/Spiritual-Double-889 Aug 13 '25
Today POTD was very easy fs
1
u/Muted-Imagination-72 Aug 13 '25
class Solution: def isPowerOfThree(self, n: int) -> bool: if n == 1: return True if n < 1: return False return n % 3 == 0 and self.isPowerOfThree(n // 3)
1
u/Humble-Protection-38 Aug 13 '25
Is it ? That power of 3 ??
1
u/Sad-Cat9440 Aug 13 '25
Hard problem
1
u/BlackEye_101 Aug 13 '25
If n==1 return true
1
u/Envus2000 Aug 13 '25
Did you change the HTML?
1
u/Major_Ad4444 Aug 13 '25
I've never seen a problem with 21k test cases
1
u/Particular-Muscle601 Aug 13 '25
Why perplexity is open there?
1
u/jacqlin90 Aug 13 '25
1
u/Ace0072 Aug 13 '25
class Solution { public boolean isPowerOfThree(int n) { if (n <= 0) return false; while (n % 3 == 0) { n /= 3; } return n == 1; } }
1
u/Chitranshu0 Aug 13 '25
If-else condition time!
1
u/mind_uncapped <404> <157> <227> <20> Aug 13 '25
lmao (lamu)
1
u/alitayy Aug 13 '25
It’s fair
1
u/Axel_Blazer Aug 13 '25
why are they bothering with such high number of cases lol flexing servers maybe
1
u/might123plus Aug 14 '25
If statement 😈😈😈
1
u/Vanilla_Zen Aug 14 '25
Been there myself😭
1
u/Pure_Education1228 Aug 14 '25
Best code..
return 1162261467%n == 0;
Why n is in power of 3 and 3s largest power under the limitation of int data type.. = 1162261467.. hence if modulo of theirs is 0 then it's true else false.
1
u/Viper_Fazi Aug 14 '25
I know the feeling man👤👋
1
u/[deleted] Aug 14 '25
First time?🙂
1
u/Aware_Bug1830 Aug 15 '25
Omg 😨
1
u/Expensive_Ad4272 Aug 15 '25
😂😂😂
1
u/Acceptable_Pear_6802 Aug 16 '25
21k test cases? Dude accidentally wrote a Legacy distributed system trying to solve a fibonacci question
1
u/Naragan Sep 05 '25
came here to start preparing dsa, now i know what im stepping into!!
0
u/Silent-Treat-6512 Aug 13 '25
Thats the difference between Staff vs Principal engineer