有一个数组随机包含数字Ex:arr [6] = {43,46,54,2,65,75}; 总和在304,所以突然有一个元素会变成零如何找到 哪个元素变为零,我们也必须找到地址。
Have an array it contain number random Ex: arr[6] ={43,66,54,2,65,75}; There sum in 304, so suddenly one element will become zero how to find which element has become zero and we have to find the address also.
推荐答案sandeep写道: sandeep wrote: 有一个数组,它包含数字随机Ex:arr [6] = {43,66,54,2 ,65,75}; 总和在304,所以突然一个元素将变为零如何找到 哪个元素已经变为零,我们也必须找到地址。 Have an array it contain number random Ex: arr[6] ={43,66,54,2,65,75}; There sum in 304, so suddenly one element will become zero how to find which element has become zero and we have to find the address also.
首先,数组的总和不是304的305. 假设总和为305,则遍历数组检查 为零并使用索引返回地址。简单:) -kondal
First the sum of the array is not 304 its 305. Assuming that the sum would be 305, traverse through the array checking for zero and return the address using the index. Its simple :) -kondal
kondal写道: kondal wrote: sandeep写道: sandeep wrote: 有一个数组,它包含数字随机Ex:arr [6] = {43, 66,54,2,65,75}; 总和在304,所以突然一个元素将变为零如何找到 哪个元素变为零并且我们有找到地址也。 Have an array it contain number random Ex: arr[6] ={43,66,54,2,65,75}; There sum in 304, so suddenly one element will become zero how to find which element has become zero and we have to find the address also.
首先,数组的总和不是304的305. 假设总和为305,则遍历数组检查 为零并使用索引返回地址。它的简单:) -kondal
First the sum of the array is not 304 its 305. Assuming that the sum would be 305, traverse through the array checking for zero and return the address using the index. Its simple :) -kondal
你的意思是说像轮询方法(反复检查完整阵列 方法)但是面试官告诉我使用其他逻辑
You mean to say like polling method ( repeatedly checking full array method ) but the interviewer told me to use other logic
sandeep写道: sandeep wrote: 有一个数组,它包含数字随机Ex:arr [6] = {43,46,54,2,65,75}; 总和在304,所以突然一个元素将成为零如何找到 哪个元素已经变为零,我们也必须找到地址。 Have an array it contain number random Ex: arr[6] ={43,66,54,2,65,75}; There sum in 304, so suddenly one element will become zero how to find which element has become zero and we have to find the address also.
首先,什么是HCL访谈? 其次,为了使总和为304,其中一个元素需要 减少1,而不是设为零。 /> 找到一个值为零的元素会很容易,就像 找到它的地址一样,但我不知道304与任何东西有什么关系。
First, what is an HCL interview? Second, in order for the sum to be 304, one of the elements would need to be reduced by 1, not set to zero. Finding an element with the value of zero would be easy, as would finding its address, but I don''t see what 304 has to do with anything.
更多推荐
HCL面试问题可以任何人说出解决方案
发布评论