Given a sorted array of 0s and 1s. The goal is to discover the index of the sorted array’s first '1'. It's possible that the array is made up entirely of 0s or 1s. If there are no 1's in the array, display "-1."
Given a sorted array of 0s and 1s. The goal is to discover the index of the sorted array’s first '1'. It's possible that the array is made up entirely of 0s or 1s. If there are no 1's in the array, display "-1."
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: easy
标签: interviewbit, ibm, company-specific
目标公司: IBM
参考答案摘要
Example: Input: arr = {0, 0, 0, 0, 1, 1, 1} Output : 4 Input : Arr = {0, 0, 0, 0} Output : -1 Approach: It is given that the array is sorted. We use this property of the array and apply binary search ...
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。