₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,012 members, 8,419,921 topics. Date: Thursday, 04 June 2026 at 07:30 AM

Toggle theme

Programming Interview Test - Programming (3) - Nairaland

Nairaland ForumScience/TechnologyProgrammingProgramming Interview Test (4242 Views)

1 2 3 Reply (Go Down)

Re: Programming Interview Test by Nobody:
jacob05:
use .. Repl.it - Python 2
Tried your code works fine but does not allow for P == 0 or P == N-1 as mentioned in the instruction:
Sum of zero elements is assumed to be equal to 0. This can happen if P = 0 or if P = N−1.
Re: Programming Interview Test by jacob05(m): 10:43am On May 26, 2016
Febup:
Tried you code works fine but does not allow for P == 0 or P == N-1 as mentioned in the instruction:
Sum of zero elements is assumed to be equal to 0. This can happen if P = 0 or if P = N−1.
It's just an implementation of crotonite's solution in Python ... not entirely mine... undecided undecided
Re: Programming Interview Test by Nobody:
jacob05:
It's just an implementation of crotonite's solution in Python ... not entirely mine... undecided undecided
I think his code is ok, but I cannot enter P = values to check his code.
Re: Programming Interview Test by Nobody: 8:01pm On May 26, 2016
cheesy grin cheesy guyz, i finaly got it 100% cool cool

here is my code...

class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
if(A == null || A.length <= 0 || A.length > 100000)
return -1;
long r = 0;

for(int i : A)
r += i;

long l = 0;

for(int p = 0; p < A.length; p++){
r -= A[p];
if( r == l)
return p;

l += A[p] ;
}
return -1;
}
}


thanks @febup for this challenge.

Re: Programming Interview Test by Nobody: 8:54pm On May 26, 2016
crotonite:
cheesy grin cheesy guyz, i finaly got it 100% cool cool

here is my code...

class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
if(A == null || A.length <= 0 || A.length > 100000)
return -1;
long r = 0;

for(int i : A)
r += i;

long l = 0;

for(int p = 0; p < A.length; p++){
r -= A[p];
if( r == l)
return p;

l += A[p] ;
}
return -1;
}
}


thanks @febup for this challenge.
You can now have the crown until the next challenge.

Re: Programming Interview Test by jacob05(m): 9:03pm On May 26, 2016
crotonite:
cheesy grin cheesy guyz, i finaly got it 100% cool cool

here is my code...

class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
if(A == null || A.length <= 0 || A.length > 100000)
return -1;
long r = 0;

for(int i : A)
r += i;

long l = 0;

for(int p = 0; p < A.length; p++){
r -= A[p];
if( r == l)
return p;

l += A[p] ;
}
return -1;
}
}


thanks @febup for this challenge.
Nice.

In Python


def solution(data ) :
if not type(data ) is list or len(data ) <= 0: return -1
lSum = 0; r = sum(data )
for p in xrange(0, len( data ) ) :
r -= data[p]
if (r == lSum ) : return p
lSum += data[p]
return -1
Re: Programming Interview Test by Nobody: 9:10pm On May 26, 2016
jacob05:
Nice.

In Python


def solution(data ) :
if not type(data ) is list or len(data ) <= 0: return -1
lSum = 0; r = sum(data )
for p in xrange(0, len( data ) ) :
r -= data[p]
if (r == lSum ) : return p
lSum += data[p]
return -1
WOW...! python seems to be more concise than java. i think i need to learn python when i master enough of java.
1 2 3 Reply

Programming Interview Question: Invert A Binary Tree234

A Very Simple Loan Calculator In Vb6 NeededCyber Security Experts - Call For MembersWhat Kind Of Technologies Will I Need To Build A Fintech Application?