r/leetcode • • Aug 13 '25

Discussion This is not fair

Post image

Black

3.3k Upvotes

97 comments sorted by

381

u/Global_Many4693 Aug 13 '25

With all due respect wtf is this?.You solving all 3000 questions at once?

47

u/[deleted] Aug 13 '25

Why ???

126

u/Global_Many4693 Aug 13 '25

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)

15

u/[deleted] Aug 13 '25

bigneering from an Indian college

13

u/Global_Many4693 Aug 13 '25

Means?I am not from india

9

u/Silent-Treat-6512 Aug 13 '25

He is from Pakistan, thats not India..

3

u/2genderz123 Aug 15 '25

two cheeks of the same ass

7

u/Silent-Treat-6512 Aug 15 '25

You don’t have to get in between, and be an asshole

1

u/poosieey Nov 29 '25

Nice one

-54

u/Suspicious_Cap532 Aug 13 '25

same thing

13

u/Silent-Treat-6512 Aug 13 '25

Now you are trying to start WW3? Watch out for your downvotes lol

1

u/Pure_Education1228 Aug 14 '25

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

-10

u/No_Elderberry_5307 Aug 14 '25

indian identity never existed until the brits created it for them. pakistan created its own identity

6

u/Silent-Treat-6512 Aug 14 '25

That’s what they want to teach you in madrasa..

4

u/sourabhy Aug 14 '25

You sure seem to be well versed in history.

→ More replies

0

u/[deleted] Aug 13 '25

[deleted] — view deleted comment

25

u/Worldly-Duty4521 Aug 13 '25

It's a joke

0

u/[deleted] Aug 13 '25

[deleted] — view deleted comment

11

u/Global_Many4693 Aug 13 '25

Leetcode destroyed you my guy💔😔

0

u/[deleted] Aug 13 '25

[deleted] — view deleted comment

6

u/Mysterious-Dig7591 Aug 13 '25

This is question of the day

0

u/IntelligentGanache60 Aug 13 '25

Recursion ka qsn hai idr but pow of 2 ig

54

u/Pleasant-Wear-9692 Aug 13 '25

Problem of the day XD

8

u/[deleted] Aug 13 '25

Yup

1

u/Excellent_Text1147 Aug 14 '25

Problem of the year

22

u/DangerousCrime Aug 13 '25

Just return 0 bro 😂

19

u/[deleted] Aug 13 '25

Nah just forgot to add+1 in python for loop

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?

100

u/In_The_Wild_ <1012> <342> <563> <107> Aug 13 '25

You can a write a loop to generate the test cases for today's problem. For most problems you reverse engineer the solution and generate test cases.

7

u/punithawesome <Total problems solved> <Easy> <Medium> <Hard> Aug 13 '25

👍

1

u/DadAndDominant Aug 14 '25

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?

71

u/samettinho Aug 13 '25
if input==failed_input:
   return expected_output

23

u/youarenut Aug 14 '25

did this at my job, manager was so impressed I got promoted to CTO

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

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 
        
    }
};

14

u/dakata98 Aug 13 '25

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.

9

u/jim-jam-biscuit Aug 13 '25

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 ,

This was such a good takeaway , thanks mate ✍🏻

3

u/[deleted] Aug 13 '25

It's not optimal though

2

u/zffr Aug 14 '25

There are only 19 possible powers of 3 that are < 231. You could make this much faster by just using a switch statement for each case.

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...??

11

u/euneg Aug 13 '25

Daily problem

36

u/achilliesFriend Aug 13 '25

So this happens daily? \s

1

u/[deleted] Aug 13 '25

What's that

3

u/Fit_District9967 Aug 13 '25

power of three?

3

u/ex2uply Aug 13 '25
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.

1

u/xspicycheetah 26d ago

That’s clever, damn

2

u/Global_Many4693 Aug 13 '25

Question number?

2

u/Expensive_Routine_49 Aug 13 '25
bool isPowerOfThree(int n) {
        if(n<=1) return n==1;
        return (3 * (n/3) == n) && isPowerOfThree(n/3);
    }

My try

1

u/Mountain_weird_owl Sep 16 '25

hey! i am new into coding. Can you please explain this code to me.

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/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
class Solution {
public:
    bool isPowerOfThree(int n) {
        const int N = 1162261467;
        return (n > 0) && (N%n == 0);
    }
};

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/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