---
# System prepended metadata

title: VINOD KUMAR MEENA

---

VINOD KUMAR MEENA
https://drive.google.com/file/d/1cLAWscEb4e6_sFhayTWO-ROl8qrggAT6/view

* qn 1 logic was correct, but syntax issues, so could not run
* qn 2- even after having expertise in NodeJS, not willing to code in JS. after insisting multiple times, he started on it
* js hands on also very average.. was very confused with syntax and in built functions
* too slow in implementing the logic
* logically correct & fast, but implementation wise below average

1) add digits
```
class Solution {

    public static String addDigitHelper(String number) {
        if(number.length() == 1) {
            // convert string to integer 
            return number;
        }

        int sum = 0;

        for(int i=0; i<number.length(); i++) {
            System.out.print((int)number.charAt(i));
            sum += (int)number.charAt(i);
        }

        System.out.println(sum);

        String strNumber = String.valueOf(sum);

        System.out.println(strNumber);

        return addDigitHelper(strNumber);
    }
    public int addDigits(int num) {
        String strNumber = String.valueOf(num);
        System.out.println(strNumber);
        String res = addDigitHelper(strNumber);
        return Integer.parseInt(res);
    }
}
```


2) js array transform

```
const input = [
    { "pincode" : 382225, "state" : "Gujarat", "city" : "Bavala" },
    { "pincode" : 600060, "state" : "Tamil Nadu", "city" : "Chennai" },
    { "pincode" : 600062, "state" : "Tamil Nadu", "city" : "Chennai" },
    { "pincode" : 600095, "state" : "Tamil Nadu", "city" : "Chennai" },
    { "pincode" : 523115, "state" : "Andhra Pradesh", "city" : "Gudlluru" },
    { "pincode" : 382240, "state" : "Gujarat", "city" : "Bavala" },
    { "pincode" : 638403, "state" : "Tamil Nadu", "city" : "Palladam" },
    { "pincode" : 370602, "state" : "Gujarat", "city" : "Dayapar" }
]

// expectd output 
// {
//     'Tamil Nadu': {
//         'Chennai': [600060, 600062, 600095], 
//         'Palladam': [638403]
//     },
//     'Gujarat': { 
//         'Bavala': [382225, 382240],
//         'Dayapar': [370602]
//     },
//     'Andhra Pradesh': { 
//         'Gudlluru': [523115]
//     }
// }



function mergeAddressArray(inputArr) {
    var resObject = {};
    for(var i=0; i<inputArr.length; i++) {
        var state = inputArr[i]["state"];
        if(!resObject[state]) {
            resObject[state] = {};
        }
        var city = inputArr[i]["city"];
        if(!resObject[state][city]) {
            resObject[state][city] = [];
        }
        resObject[state][city].push(input[i]["pincode"]);
    }

    return resObject;
}

console.log(mergeAddressArray(input));
```