Round 1
Questions:
-
Task 1:
Task 1 Solution:
import java.util.*; class Solution { public int solution(int[] blocks) { int n = blocks.length; int[] farRight = new int[n]; int farR = n - 1; for (int i = n - 1; i >= 0; i--) { if (i + 1 < n && blocks[i] > blocks[i + 1]) { farR = i; } farRight[i] = farR; } int farLeft = 0; int ans = 0; for (int i = 0; i < n; i++) { if (i - 1 >= 0 && blocks[i - 1] < blocks[i]) { farLeft = i; } ans = Math.max(ans, farRight[i] - farLeft + 1); } return ans; } }
-
Task 2:
Task 2 Solution:
import java.math.BigInteger; class Solution { public int solution(String S) { BigInteger num = new BigInteger(S, 2); BigInteger two = new BigInteger("2"); int countSteps = 0; while (!num.equals(BigInteger.ZERO)) { if (num.mod(two).equals(BigInteger.ZERO)) { num = num.divide(two); } else { num = num.subtract(BigInteger.ONE); } countSteps++; } return countSteps; } }
Didn't pass all the test cases for this problem.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Other Experiences:
- Zepto Interview Experience
- Salesforce OA
- Arcesium OA
- Google Interview Experience
- ServiceNow Interview Experience
- JP Morgan & Chase OA
- Microsoft Interview Experience
- Goldmann OA
LLD | Full Working Code: