Cars24 | Senior Software Engineer | Gurgaon | Bad Experience | Feb 2024 [Reject]

1998
Mar 04, 2024

Y.O.E - 8 years
Position: Senior Software Engineer
Location: Gurgaon
Date: February 2024

Round-1
In this round we had discussion on multiple topics like Java some database discussions and kafka related topics, some of the questions which i can remember are below:

Java Related

* Java generics/ Outbound Context
* Streams/ parallel streams/ Consumer, Predicate, Intermediate and terminal operations on Streams
* In Parallel Stream how java decides how many threads to create
* Java8 features Lambda expressions , Functional Interfaces
* Heap restructure in java8, like metaspace added, what is it used for? why permgen removed
* What types of new GCs have been added in the new java version? and how they do work internally
* Hashmap changes in java8, how it worked prior to java8 and what are changes done, what is the complexity of Btree etc, 
* What is concurrentHashMap and its usage
* Reentrant Locks vs Synchronization differences, which one to use and how they differ inetrnally

SQL Related

* Suppose 2 Concurrent transactions are trying to update one single row, 
which txn will get the lock first? How will you handle this scenario? will optimistic locking will be sufficient here? 
how can you make sure that the request which came first to the server always gets the lock of that row 
( Example of it, 2 users trying to book the same seat on BookmyShow website, how can we make sure the first users gets the seat always)
* What is a two phase commit (2PC), 3 phase commit?
* What is dirty reads
* What are different isolation levels and their usages?
* Difference between partitioning and indexing in table
* When to create a composite index? and how composite index filters the data qhile querying

Kafka Related

* What are partitions in kafka topic
* How many consumers can be attached to a single partition of a single consumer group?
* If we attach multiple consumers of the same consumer group to a single partition? Will it cause any problem? Will it help in consuming records faster? 
* What will happen if we increase the number of partitions of a kafka topic in a production running application? How will it behave? how rebalancing will happen? 
* What is the partition key? How to define a partition key and what is the advantage of it?

This Round really went well for me, I was able to answer almost all the questions correctly and the interviewer was looking satisfied also,

Round-2
This was a system design Round, and the same interviewer was there who took my first round, so here is the problem statement:
Design Splitwise Application system (Database schema, APIs, then services involved), where we have the following functionalities

Functional Requirements:
- User does registration (manual/ via invitation)
- user can create groups
- user can create expenses / Group expenses
- Edit Expenses
- Amount can be slitted equally or by some ratio (Custom split)
- Settle the balances (by cash/online)
- Free/Premium Features
- History for each action being tracked (User wise)


NFR
- Consurrency handling
- Fault tolerance/ Scale

This round didn't go very well for me, I tried to create simple tables to keep all the required data and do various operations, but he seemed not liking it much, he was very concerned about little things, like, why are you not keeping the status in the user table, so that we know if it in active/inactive user, and you should keep the column also like, created_at, created_by and other basic columns,

these things initially i did not created in the db schema ,as my main focus was to do the main operations like , adding expenses, calculating the amounts, settlement and all, so obviously in 10-15 minutes no one will be able to create a full fledged complete database tables and all the required column, i feel this expectation itself is wrong,

then while were discussing all this, time ended, and the discussion didn't complete , he said can we do this discussion on some other day, i said ok lets do it,

then i got a call from the recruiter saying that the interviewer is saying that he wants to do the discussion again with you since the last round was not completed on time, I told ok lets schedule it one more time, Now comes the last round:

Round-3:
In this Round there was some other interviewer this time, not that person who wanted to have the discsussion again , and this wound was focused on LLD part (what i thought atleast).

Below problem statement was given by him in a coderpad

/**

We have an Ecommerce System where we have different services built already, your task is to build an InventoryOrchestratorService which will be responsible to save the cart state basis on different events happening in the system

CartService - managing the lifecycle of the cart

PUT /api/v1/cart 

products
quantities
discountCode
deliveryLocation

Orchestrator Service can use the following already builtin service
- InventoryService - check the availability of the inventory
- PricingService - check the pricing and taxes
- DiscountingService - calculated discounted prices
- DeliveryService - check deliverability and calculate delivery charges
- FraudDetectionService - 

NFRs
- Fault tolerant and resilient
- Extensible


Functional Requirements (events) we have to handle
* New Item Added into the card
* Exisitng Item Qty Updated (Added/Reduced)
* Change the delivery location
* User Apply some coupon code
* Cart update basis on inventory update
*/

I wrote the xomplete java code for the above requirements which i am mentioning below as well, I wrote it as fast as i could, but the interviewer was looks like he was sleeping, he turned his camera off, went on mute, and spoke nothing, no questions nothings, i was continously speaking while writing the code that i am assuming these things and why i am writing a particular function and all, but there was no response at all from the other end.

When i was done from my side writing all the code, finally he unmuted himself and asked only one followup question that what changes you will make to your classes if you need to a fraudulent check before doing each operation, i explained the changes required and the interview was over.

below is my java code which i wrote it.

class Cart {

    private int id;
    private String couponCodeApplied;
    private Integer totalPrice;
    private Map<Integer, Integer> cartItems;
    private InventoryService InventoryService;
    private Integer pincode;
    private PricingService pricingService;
    
    public Cart(Integer itemId, Integer pincode, PricingService pricingService){
        cartItems = new HashMap<>();
        cartItems.put(itemId, 1);
        this.pincode = pincode;
        this.pricingService = pricingService;
        this.totalPrice = pricingService.getPrice(itemId);
    }

    public synchronized void addItem(Integer itemId, Integer quantity){
        if(!cartItems.containsKey(itemId)){
            cartItems.put(itemId, 0);
        }
        Integer priceForNewItem = pricingService.getPrice(itemId) * quantity;
        this.totalPrice = this.totalPrice + priceForNewItem;
        cartItems.put(itemId, cartItems.get(itemId) + quantity);
    }

    public synchronized void removeItem(Integer itemId, Integer quantity){
        if(!cartItems.containsKey(itemId)){
            return;
        }
        Integer currentQty = cartItems.get(itemId);
        if(currentQty < quantity){
            throw new IllegalArgumentException("can not reduce greater than existing qty ");
        }
        Integer priceForNewItem = pricingService.getPrice(itemId) * quantity;
        this.totalPrice = this.totalPrice - priceForNewItem;
        cartItems.put(itemId, cartItems.get(itemId) - quantity);
    }

    public void changePincode(Integer pincode){
        this.pincode = pincode;
    }

    public synchronized void couponApplied(String couponCode, Integer value){
        couponCodeApplied = couponCode;
        this.totalPrice = this.totalPrice - value;
    }
}

class Item {
    int id;
    String desc;
    // other details of the item goes here
}


class CartStateManagerProxy extends CartStateManager{
    
    private CartStateManager statemanger;

    private FraudDetectionService fraudDetectionService;
    
    public CartStateManagerProxy(FraudDetectionService fraudDetectionService){
        this.fraudDetectionService = fraudDetectionService;
    }
    
    @Override
    public void quantityUpdate(Integer cartId, Integer itemId, Integer quantity){   
        valid = fraudDetectionService.checkCustomerFraudlent();
        if(!valid){
            throw new Exception("customer is fraud");
        }
        statemanger.quantityUpdate(cartId, itemId, quantity);
    }
}

class CartStateManager {

    private Map<Integer, Cart> carts;
    private DeliveryService deliveryService;
    private InventoryService inventoryService;
    private DiscountingService discountingService;

    CartStateManager(InventoryService inventoryService, DeliveryService deliveryService, DiscountingService discountingService){
        carts = new ConcurrentHashMap<>();
        this.deliveryService = deliveryService;
        this.inventoryService = inventoryService;
        this.discountingService = discountingService;
    }

    public void newCartCreated(Cart cart){
        if(carts.containsKey(cart.id)){
            throw new IllegalArgumentException("a cart is already exist with the given id");
        }
        carts.put(carts.id, cart);
    }

    public void quantityUpdate(Integer cartId, Integer itemId, Integer quantity){
        if(quantity == 0) {
            return;
        }
        if(quantity > 0) {
            boolean available = inventoryService.hasEnoughtQty(itemId, quantity);
            if(!available){
                throw new IllegalStateException("item does not have sufficient qty");
            }
            inventoryService.reduceItemQuantity(itemId, quantity);
            carts.get(cartId).addItem(itemId, quantity);
        } else {
            inventoryService.addItemQuantity(itemId, quantity);
            carts.get(cartId).reduceItem(itemId, quantity);
        }
    }

    public void onDeliveryLocationUpdate(Integer cartId, Integer pincode){
        boolean servicable = deliveryService.pincodeServiceable(pincode);
        if(!servicable){
            throw new IllegalArgumentException("pincode is not valid");
        }
        cart.get(cartId).changePincode(pincode);
    }

    public void applyCouponCode(Integer cartId, String couponCode) throws InvalidCouponCodeException {
        Integer value = discountingService.calculateCouponCodeValue(couponCode);
        cart.get(cartId).couponApplied(couponCode, value);
    }
}

class InvalidCouponCodeException extends Exception{
    
    public InvalidCouponCodeException(){
        super();
    }

    public InvalidCouponCodeException(String message){
        super(message);
    }
}

then i got no response from anyone for 2 weeks, then I sent an email to all of them mentioning why they are being so unprofessional, then after 5 minutes i received the response that they are not moving ahead with my profile as they do not have sufficient opennings

Comments (3)