Equilibrium Point | Daily Dose - 5 | Interview Questions | Geeks for Geeks | Tamil | code io

Equilibrium Point | Daily Dose - 5 | Interview Questions | Geeks for Geeks | Tamil | code io

code io - Tamil

3 года назад

5,698 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@nithishkumark1644
@nithishkumark1644 - 17.06.2021 19:41

Nalla question da👍👍👍

Ответить
@anandhar9329
@anandhar9329 - 21.06.2021 05:27

Nice question 🔥🔥

Ответить
@karthekeyanz
@karthekeyanz - 03.11.2021 09:02

// Time complexity: O(N) + Space complexity: O(1)

int equilibriumPoint(long numbers[], int n) {

if (numbers == null || n == 0) return -1;
if (n == 1) return 1;

long totalSum = 0;
for (int i = 0; i < numbers.length; i++) totalSum += numbers[i];

long leftSum = numbers[0];
for (int i = 1; i < numbers.length; i++) {
long rightSum = totalSum - leftSum - numbers[i];
if (leftSum == rightSum) return i + 1;
leftSum += numbers[i];
}
return -1;
}

Ответить
@mohammedfahadfs6235
@mohammedfahadfs6235 - 09.02.2022 00:09

BRo eqpoint is never used here

Ответить
@012arjun.b6
@012arjun.b6 - 10.02.2022 06:44

Enna language bro use pannirikinga

Ответить
@SAKSHIKUMARIP
@SAKSHIKUMARIP - 19.02.2022 09:07

Nice explanation bro

Ответить
@nagaarjun1592
@nagaarjun1592 - 17.05.2023 13:59

Anna indha array la last value 0 va irundhuchuna

Ответить
@Code_Leveler
@Code_Leveler - 15.01.2024 09:27

public class equillibrium {
public static int Arrayequillibrium(int arr[],int n)
{
int left=0;
int right=n-1;
int mid=n/2;
int ans1=0;
int ans2=0;
while(left<mid&&right>mid)
{
ans1+=arr[left];
left++;
ans2+=arr[right];
right--;
}
if(ans1==ans2)
return mid;
else
return -1;

}
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] arr={ -7, 1, 5, 2, -4, 3, 0 };
int n=arr.length;
System.out.print(Arrayequillibrium(arr,n));

}

}
bro naa 2 years late for commenting my code😂

Ответить
@_SANJAYM
@_SANJAYM - 28.07.2024 20:16

Worst explain

Ответить
@praveennarayanansj9263
@praveennarayanansj9263 - 13.08.2024 18:03

bro how to think like this?

Ответить