## Amazon Interview Question for Software Developers

• 0

Country: United States

Comment hidden because of low score. Click to expand.
0
of 0 vote

void FindSubarraySum(vector<int>vint,int low,int high)
{
int count = 0;
int subsum = 0;

for(int i = 0;i<vint.size();i++)
{
subsum = 0;
for(int j=i;j>=0;j--)
{
subsum += vint[j];
if(subsum >= low && subsum <= high)
{
count++;
}
}
}

cout<<count<<endl;
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

void FindSubarraySum(vector<int>vint,int low,int high)
{
int count = 0;
int subsum = 0;

for(int i = 0;i<vint.size();i++)
{
subsum = 0;
for(int j=i;j>=0;j--)
{
subsum += vint[j];
if(subsum >= low && subsum <= high)
{
count++;
}
}
}

cout<<count<<endl;
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````void FindSubarraySum(vector<int>vint,int low,int high)
{
int count = 0;
int subsum = 0;

for(int i = 0;i<vint.size();i++)
{
subsum = 0;
for(int j=i;j>=0;j--)
{
subsum += vint[j];
if(subsum >= low && subsum <= high)
{
count++;
}
}
}

cout<<count<<endl;
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````void FindSubarraySum(vector<int>vint,int low,int high)
{
int count = 0;
int subsum = 0;

for(int i = 0;i<vint.size();i++)
{
subsum = 0;
for(int j=i;j>=0;j--)
{
subsum += vint[j];
if(subsum >= low && subsum <= high)
{
count++;
}
}
}

cout<<count<<endl;
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

solution in Scala:

``````object SumSubsequence {
def main(args: Array[String]): Unit = {
val subArray = Array(1,2,3)
val interval = (3,6)
println(getCountSumSubarray(subArray, interval))
}

def getCountSumSubarray(subArray : Array[Int], interval : (Int,Int)) : Int = {

var count = 0 // to count num of subsequenecs within range
var sum = 0
val n = subArray.length

for (i <- 0 until n) {
for (j <- i until n) {
for (k <- i to j) {
sum += subArray(k)
print(subArray(k))
}
println(" - sum = " + sum)

if (sum >= interval._1 && sum <= interval._2) {
count += 1
}
sum = 0
}
}
count
}
}``````

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.