Summary
I had a one-hour technical interview with Cashfree on Hackerrank, where I was asked two questions: one DSA in C++ and one JavaScript problem. I was ultimately rejected.
Full Experience
Interview Experience – Hackerrank (1 Hour, C++, JavaScript)
I had a one-hour technical interview on Hackerrank where I was asked two questions. One was a DSA question to be coded in C++, and the other was based on JavaScript.
Q1. Leetcode 658 – Find K Closest Elements
Link: https://leetcode.com/problems/find-k-closest-elements/description/
Given a sorted array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order.
An integer a is closer to x than an integer b if:
|a - x| < |b - x|, or|a - x| == |b - x|anda < b
Example Input:
arr = [1,2,3,4,5], k = 4, x = 3
Output: [1,2,3,4]
My C++ Code:
#include <cmath>
#include <cstdio>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int addNumbers(int a, int b) {
return a+b;
}
// // // // // Input: arr = [1,2,3,4,5], k = 4, x = 3
int main() {
// int size;
vector<int>arr={23, 45, 67, 98};
int k=2;
int x=75;
// cin>>size;
// for (int i=0;i<size;i++){
// int temp;
// cin>>temp;
// arr.push_back(temp);
// }
vector<pair<int ,int>> diff;
// vector<int> diff(arr.size(),0);
for(int i=0;i<arr.size();i++){
diff.push_back({abs(arr[i]-x),i});//O(n)
// diff[i]=abs(arr[i]-x);
}
priority_queue<pair<int,int>>pq;
for(int i=0;i<arr.size();i++){
pq.push({diff[i].first,diff[i].second});//O(nlog(k))
if(pq.size()>k) pq.pop();
}
vector<int>ans;
while(pq.size()){
pair<int,int> temp=pq.top();
ans.push_back(arr[temp.second]);//O(k)
// cout<<arr[temp.second];
pq.pop();
}
sort(ans.begin(),ans.end());//O(k*log(k))
for(int x:ans) cout<<x<<" ";
return 0;
}
Q2. JavaScript – Flatten a Deeply Nested Array
Given a nested array like:
const nestedArray = [1, [2, 3], [4, [5]]];
Write a function to flatten it without using inbuilt functions like .flat().
Note: Interviewer asked to avoid inbuilt .flat() and recursion was allowed.
What I Said:
I suggested using recursion and checking if the element is an array using Array.isArray(), but I couldn’t complete the code in time.
What I initially wrote:
const flattenedArray = deeplyNestedArray.flat(Infinity);
Expected Approach Using Recursion (Not allowed to use .flat()):
Verdict : Rejected
Interview Questions (2)
Given a sorted array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order.
An integer a is closer to x than an integer b if:
|a - x| < |b - x|, or|a - x| == |b - x|anda < b
Example Input:
arr = [1,2,3,4,5], k = 4, x = 3
Output: [1,2,3,4]
Given a nested array like:
const nestedArray = [1, [2, 3], [4, [5]]];
Write a function to flatten it without using inbuilt functions like .flat().
Note: Interviewer asked to avoid inbuilt .flat() and recursion was allowed.
Summary
I participated in Cashfree's Frontend Intern online assessment in mid-June, which included general knowledge questions and three coding problems, and I was selected for the interview round.
Full Experience
I had Participated in Cashfree Frontend Intern on mid of june had my OA scheduled and was asked 5 on Error codes , linkedList ,user experience and graph later I had 3 question 2 dsa question and 1 node.js (javascript Q). verdict selected for interview
Interview Questions (3)
Problem: Distinct One Counts After One Flip
You are given a binary array arr of length n, consisting only of 0s and 1s.
You are allowed to choose exactly one subarray (possibly empty) and flip all of its elements — that is, convert all 0s in the subarray to 1s, and all 1s to 0s.
Your task is to determine how many distinct values for the total number of 1s in the array can be obtained after performing exactly one flip operation.
Function Signature
int getDistinctOneCounts(vector<int> arr);
Input
arr: A vector ofnintegers, where each element is either0or1.- Constraints:
- $1 \leq n \leq 2 \times 10^5$
- Each element of
arris either0or 1.
Output
- Return an integer representing the number of distinct possible counts of 1s in the array after exactly one subarray flip operation.
Note
- A subarray is a contiguous portion of the array.
- You are allowed to flip an empty subarray, which results in no change to the array.
Example
Input
arr = [0, 1, 1, 0]
Output
4
Explanation
Possible flips and resulting 1-counts:
| Subarray Chosen (0-based indices) | Flipped Array | Number of 1s |
|---|---|---|
| None (empty subarray) | [0, 1, 1, 0] | 2 |
| [0, 0] | [1, 1, 1, 0] | 3 |
| [1, 2] | [0, 0, 1, 0] | 1 |
| [0, 3] | [1, 0, 0, 1] | 2 |
| [0, 1] | [1, 0, 1, 0] | 2 |
| [2, 3] | [0, 1, 0, 1] | 2 |
| [1, 3] | [0, 0, 0, 1] | 1 |
| [0, 2] | [1, 0, 0, 0] | 1 |
| [1, 2] | [0, 0, 0, 0] | 0 |
The distinct counts of 1s after these flips are: {0, 1, 2, 3} → total 4 distinct values.
Problem: Custom Auction System
You are building a custom auction system with unique bidding rules:
- An auction starts with an initial price.
- Bidders can place bids via
updatePrice, but only if their bid is higher than the current bid. - To win the item, a bidder must explicitly claim it using
callBidwith a valid offer. - Once an item is claimed via a successful
callBid, no further bids or claims are allowed on it.
Function Definitions
You need to implement the following three functions to manage the auction process:
1 startAuction(auctions, entity, startingPrice)
Starts an auction for a given item.
- Parameters:
auctions(object): A shared object that stores all auctions.entity(string): The name of the item.startingPrice(number): The minimum price to start the auction.
- Returns: Nothing (updates the
auctionsobject).
2 updatePrice(auctions, entity, bidPrice)
Places a new bid for the item.
- A new bid is only accepted if it is greater than both the starting price and the current highest bid.
- Bids are ignored if the item has already been claimed.
- Parameters:
auctions(object): The shared auction data.entity(string): The item being bid on.bidPrice(number): The new bid price.
- Returns: Nothing (updates the bid in
auctions).
3️ callBid(auctions, entity, callPrice)
Attempts to claim the item with a final offer.
- If the item is unclaimed and the
callPriceis greater than or equal to the current bid, the call is "successful" and the item is marked as sold. - Otherwise, the call is "unsuccessful".
- Parameters:
auctions(object): The shared auction data.entity(string): The item to claim.callPrice(number): The price the bidder wants to claim the item at.
- Returns:
"successful"or"unsuccessful"
Sample Test Case 0
Input
startAuction vase 100
updatePrice vase 150
updatePrice vase 200
callBid vase 210
Output
successful
Explanation:
- Auction for
vasestarts at 100. - Bids of 150 and 200 are valid and update the price.
- A callBid of 210 is higher than the current bid (200) — item is claimed.
Sample Test Case 1
Input
startAuction car 5000
callBid car 4500
callBid car 5000
Output
unsuccessful
successful
Explanation:
callBidof 4500 is below starting price — rejected.callBidof 5000 is equal to starting price — accepted.
Constraints
- Item names are unique lowercase English strings (
1 ≤ length ≤ 100). 1 ≤ startingPrice, bidPrice, callPrice ≤ 10^5.- Once claimed, no further updates or claims are allowed on that item.
Summary
I interviewed with CashFree for an on-campus role, which involved three technical rounds and one HR round. The first technical round focused on a challenging coding problem involving complementary string pairs.
Full Experience
My interview process with CashFree, conducted on campus, consisted of four rounds: three technical and one HR.
In the first round, I was given a coding question. The interviewer asked me to find the number of complementary pairs from a given vector of strings. A pair (i,j) is complementary if the concatenation of s[i] and s[j] (where i != j) results in a string for which any permutation is a palindrome. The interviewer specifically looked for an O(N) approach.
The second round delved into Computer Science fundamentals, covering topics like Computer Networks (CN), Operating Systems (OS), and Database Management Systems (DBMS).
The third round revolved around my projects. I explained my projects in detail, and the interviewer asked follow-up questions related to them.
Finally, there was an HR round.
Interview Questions (1)
Given a vector of strings, find the number of complementary pairs. A complementary pair (i,j) (where i!=j) is defined such that if you concatenate the string at the i-th position and the string at the j-th position, any permutation of the resulting concatenated string forms a palindrome. The pairs (i,j) and (j,i) are treated as the same.
Example:
I/P: ["aba","abc","d","aa"]
O/P: 2 (Pairs: "aba" + "aa", "d" + "aa")
The interviewer specifically asked for an O(N) approach.
Summary
I recently interviewed for an SDET position at CashFree. The process included four rounds, covering coding challenges, in-depth technical discussions on various CS fundamentals, and a final HR interaction. I successfully cleared all rounds and received an offer.
Full Experience
My interview journey at CashFree began with Round 1, which featured two coding questions. I managed to solve one: finding all palindromic substrings in a given string, which was a LeetCode Medium problem. The second was a hard DP problem where I explained two approaches but couldn't fully solve it even with a hint.
Round 2 also consisted of three coding challenges. I successfully solved 'Search in Rotated Sorted Array' (LeetCode Medium) and 'Find the Cheapest Flights With K Stops' (LeetCode Medium). The third question was 'Edit Distance', a LeetCode Hard DP problem, which I also managed to solve.
In Round 3, the discussion moved beyond coding. We delved into my internship experiences and projects. The interviewer also tested my fundamental knowledge across various computer science domains, including RDBMS, OOPS, Computer Networks, and Operating Systems. Specific questions included: 'Why do we use HTTP?', 'What's the difference between WebSocket and HTTP?', 'Why do we create different schemas?', 'What's the difference between SQL and NoSQL?', and a discussion on different paging algorithms. I was also asked to write a few SQL queries.
The final Round 4 was with HR. We discussed my future career goals, my interest in the Fintech industry, and specifically why CashFree. We also touched upon my hobbies and other general topics.
Following these rounds, I awaited the results and was pleased to receive an offer with a CTC of 22 lacs, including a 10 lac base and 1 lac variable.
Interview Questions (9)
Given a string, find all possible palindromic substrings within it.
Given a sorted array that has been rotated at some unknown pivot, search for a target element's index.
Given a list of flights and their costs, find the cheapest price to travel from a source city to a destination city with at most K stops.
Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. The allowed operations are insert a character, delete a character, or replace a character.
Explain the fundamental reasons and role of HTTP in web communication.
Describe the key differences between HTTP and WebSocket protocols, including their connection models, use cases, and advantages/disadvantages.
Explain the reasons and benefits behind creating and using different schemas in a database system (e.g., for organization, security, access control).
Discuss the fundamental differences between SQL (relational) and NoSQL (non-relational) databases, covering aspects like data models, scalability, flexibility, and typical use cases.
Discuss various paging algorithms used in operating systems for memory management, explaining their principles and common examples (e.g., FIFO, LRU, Optimal).