---
# System prepended metadata

title: Sarthak Jain

---

Sarthak Jain
https://drive.google.com/file/d/17L6Fe3Rr0ZNfOCg4xqgVa1icwn8IXApg/view

Positive

1) solved all questions
2) able to explain well
3) js hands on looks pretty good
4) last qn solved in brute force way. able to explain optimised method also. didnt ask to implement as it was clear he can do
5) thinking directions are pretty logical
6) communication & attitude ++


1) Add digits
```
/**
 * @param {number} num
 * @return {number}
 */

 function getResult (num) {
     let answer = 0;
     // 38
         while (num > 0) {
        const digit = num % 10;  // 8 3
        answer = answer + digit; // 8 11
        num = Math.floor(num / 10); // 3 0
    }
    return answer;
 }
var addDigits = function(num) {
    let answer = getResult(num);
    while (answer > 9) {
        answer = getResult(answer);
    }
    console.log('this is answer', answer);
    return answer;
};
```

2) array transform
```

// let result = input.groupby('state');
// console.log('result', result);

let result = {};

input.forEach(obj => {
    let { city, state, pincode } = obj;
    // console.log( city, state, pincode);
    if (result[state]) {
        if (result[state][city]) {
            result[state][city].push(pincode);
        } else {
            result[state][city] = [pincode];
        }
    } else {
        result[state] = {
        }
        result[state][city] = [pincode]
    }
})

console.log('Result', result)
```

3) steps to make array non decreasing (LC)
```
/**
 * @param {number[]} nums
 * @return {number}
 */
var totalSteps = function(nums) {
    let isNonDecreasing = true;
    let newArr = [];
    let count = 0;
    while (isNonDecreasing) {
        isNonDecreasing = false;
        newArr = [nums[0]];
        for (let i = 1; i < nums.length; i++) {
            if (nums[i] < nums[i-1]) {
                isNonDecreasing = true;
                continue;
            } else {
                newArr.push(nums[i]);
            }
        }
        // return count;
        if (isNonDecreasing) {
            count ++;
            nums = newArr;
        } else {
            return count;
        }
    }

};
count = 2;
// [5,3,1,2,7,3,6,11,8,5,11] -> [5,7, 11, 11]
// [5,3,4,4,7,3,6,11,8,5,11] -> [5,7,11,11]
// [5,]
```