We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents cc5d01b + f0b036e commit b152bf6Copy full SHA for b152bf6
1 file changed
Week03/pyramid_beytullah_arslan.py
@@ -0,0 +1,15 @@
1
+def calculate_pyramid_height(number_of_blocks):
2
+ if number_of_blocks <= 0:
3
+ return 0
4
+ height = int((-1 + (1 + 8 * number_of_blocks) ** 0.5) / 2)
5
+ return height #O(1)
6
+
7
+# def calculate_pyramid_height(number_of_blocks):
8
+# number_of_blocks = 1
9
+# while True:
10
+# if blocks < height:
11
+# height = height-1
12
+# break
13
+# blocks = blocks - height
14
+# height += 1
15
+# return height O(n)
0 commit comments