Skip to content

Commit df40631

Browse files
committed
Refactor
Define and set variables only where needed
1 parent 8cd56c0 commit df40631

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Diff for: CodeWars/src/TheHotelWithInfiniteRooms/Solution1.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
long long int groupSize(long long int S,long long int D)
22
{
3-
long long n, priorSum, T;
3+
long long T;
44
if(S>1)
55
{
6-
n = S - 1;
7-
priorSum = n*(n+1)/2;
6+
long long n = S - 1;
7+
long long priorSum = n*(n+1)/2;
88
T = D + priorSum;
99

1010
}
1111
else
1212
{
13-
priorSum = 0;
1413
T = D;
15-
1614
}
1715
return ceil((-1 + sqrt(1 + 8*T))/2);
1816

0 commit comments

Comments
 (0)