MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / integerBreak

Method integerBreak

343. Integer Break/Solution.cpp:17–27  ·  view source on GitHub ↗

2 <= n <= 58

Source from the content-addressed store, hash-verified

15public:
16 // 2 <= n <= 58
17 int integerBreak(int n) {
18 if (n == 2) return 1;
19 if (n == 3) return 2;
20 if (n == 4) return 4;
21 int n3 = 0;
22 while (n >= 5) {
23 n3 ++ ;
24 n -= 3;
25 }
26 return fast_pow(3, n3) * n;
27 }
28
29 int fast_pow(int x, int y) {
30 int res = 1;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected