We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7b12e00 commit 40b1eb2Copy full SHA for 40b1eb2
scripts/algorithms/G/Get Maximum in Generated Array/Get Maximum in Generated Array.java
@@ -1,13 +1,14 @@
1
+// Runtime: 1 ms (Top 71.82%) | Memory: 41.2 MB (Top 34.16%)
2
class Solution {
3
public int getMaximumGenerated(int n) {
4
if(n==0 || n==1) return n;
-
5
+
6
int nums[]=new int [n+1];
7
8
nums[0]=0;
9
nums[1]=1;
10
int max=Integer.MIN_VALUE;
11
12
for(int i=2;i<=n;i++){
13
if(i%2==0){
14
nums[i]=nums[i/2];
@@ -19,4 +20,4 @@ public int getMaximumGenerated(int n) {
19
20
}
21
return max;
22
-}
23
+}
0 commit comments