---
# System prepended metadata

title: Tanay D. Gawali | R1 | 2 yrs exp

---

# Tanay D. Gawali | R1 | 2 yrs exp

- Scala, Java
- SQL
- Unable to answer questions properly. 
- Please skip

# Question 1: Find the max sum in an array.
- Every element you choose, ith index, cannot pick i-1th index and i+1th index number. 

[1, 2, 3, 4, 5] - (1, 3, 5) - 9
[1, 2,-3, 4, 5] - (2, 5) - 7

```cpp=
int f(vector<int>A, i, sum, ans)
{
    int sum=0;
    int n=A.size();
    if(i==n)return ans;
    for(int j=2;j<n;j++)
    {
        int ans = max(ans,f(A, i, sum+A[i+j], ans));
    }
    return ans;
}

int main()
{
     vector<int>A;
    //intialize
    return f(A,0,0, 0);
}



```


# Question 2: Find the count of superstar element in an array. 
- A superstar element is an element whoes value is greater than all the values in greater index range(towards the right side.)

[1, 2, 13, 4, 10, 6, 7]

```cpp=

int f(vector<int> &A)
{
    int n=A.size(), ss= A[n-1];
    int right_max=A[n-1];
    int count=0;
    if(n==1)return 1;
    for(int i=n-2;i>=0;i--)
    {
        if(A[i]>right_max)
        {  count++; right_max=A[i];}
        //right_max=max(A[i],right_max);
    }
    return count;
}

//1 2 13 4 10 6 7

//     13  13 13 10  10 7 7

1 2 10 4 13 6 7
    
```

# Question 3: 

[1, 2, 3, 1, 2, 3, 1, 3, 4, 2, 3, 1]

maxWeight = 6

1 1 1 1 2 2 2 3 3 3 3 4



 1 2 3 |2 3 |3 1 2|4 1 1

1 1 1 1 2| 2 2 |3 3 |3 3 |4

1 1 1 1 2| 2 2 |3 3 |3 3 |4






