Skip to content

Instantly share code, notes, and snippets.

@stephen-maina
Created May 6, 2015 06:20
Show Gist options
  • Save stephen-maina/693b832c01c6b91908a6 to your computer and use it in GitHub Desktop.
Save stephen-maina/693b832c01c6b91908a6 to your computer and use it in GitHub Desktop.
success
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