Created
May 6, 2015 06:20
-
-
Save stephen-maina/693b832c01c6b91908a6 to your computer and use it in GitHub Desktop.
success
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
public int[] solution(int[] A, int[] B) { | |
int n = A.length; | |
int[] ladder = new int[n + 1]; | |
ladder[0] = ladder[1] = 1; | |
for (int i = 2; i <= n; i++) { | |
ladder[i] = ladder[i - 1] + ladder[i - 2]; | |
} | |
for (int i = 0; i < n; i++) { | |
A[i] = ladder[A[i]] & ((1 << B[i]) - 1); | |
} | |
return A; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment