Add office photos
Urban Company logo
Employer?
Claim Account for FREE

Urban Company

3.4
based on 1.1k Reviews
Video summary
Filter interviews by
Software Developer
Fresher
Skills
Clear (1)

10+ Urban Company Software Developer Interview Questions and Answers

Updated 24 Sep 2024

Q1. Meeting Rooms Allocation Problem Statement

Stark Industry is planning to organize meetings for various departments in preparation for Stark Expo. Due to limited rooms in Stark Tower, the goal is to allocate mee...read more

Ans.

Determine the minimum number of conference rooms needed to schedule meetings without overlap.

  • Sort the meetings by start time.

  • Iterate through the meetings and keep track of the rooms in use.

  • If a meeting starts after another ends, it can reuse the same room.

  • If a meeting starts before another ends, a new room is needed.

  • Return the maximum number of rooms in use at any point.

Add your answer
right arrow

Q2. Maximize XOR Value

You are provided with an integer X and are tasked with identifying an integer Y such that the bitwise XOR operation between X and Y yields the maximum possible value. The condition is that Y ...read more

Ans.

Find an integer Y such that XOR operation with X yields maximum value within given constraints.

  • Iterate from the most significant bit to find the highest bit that can be toggled to maximize XOR value.

  • To maximize XOR value, toggle the highest bit of X to 0 and all lower bits to 1.

  • Ensure the final Y does not exceed (2^61) - 1.

  • Example: For X = 3, the highest bit to toggle is at position 61, so Y = 2305843009213693950.

  • Example: For X = 7, the highest bit to toggle is at position 60...read more

Add your answer
right arrow
Urban Company Software Developer Interview Questions and Answers for Freshers
illustration image

Q3. Print All Subsets Challenge

Given an array arr containing 'N' distinct integers, your task is to generate all possible non-empty subsets of this array.

Note: While the elements within each subset should be in i...read more

Ans.

Generate all possible non-empty subsets of an array of distinct integers.

  • Use recursion to generate all subsets by including or excluding each element in the array.

  • Maintain a current subset and add it to the result when reaching the end of the array.

  • Ensure elements within each subset are in increasing order.

  • Handle the input and output format as specified in the question.

Add your answer
right arrow

Q4. Minimize Maximum Difference Between Adjacent Elements

You are provided with a non-decreasing array and an integer K. Your task is to remove exactly K elements from this array so that the maximum difference betw...read more

Ans.

Remove K elements from a non-decreasing array to minimize the maximum difference between adjacent elements.

  • Sort the array in non-decreasing order.

  • Iterate through the array and calculate the difference between adjacent elements.

  • Remove elements to minimize the maximum difference.

  • Return the minimized maximum difference.

Add your answer
right arrow
Discover Urban Company interview dos and don'ts from real experiences

Q5. Implement indexOf Function

You are provided with two strings A and B. Your task is to find the index of the first occurrence of A within B. If A is not found in B, return -1.

Example:

Input:
A = "bc", B = "abcd...read more
Ans.

Implement a function to find the index of the first occurrence of one string within another string.

  • Iterate through the second string and check if a substring of the same length as the first string matches the first string.

  • Return the index of the first occurrence of the first string within the second string, or -1 if not found.

  • Handle edge cases like empty strings or when the first string is longer than the second string.

Add your answer
right arrow

Q6. Frequency in a Sorted Array Problem Statement

Given a sorted array ARR and a number X, your task is to determine the count of occurrences of X within ARR.

Note:

  • If X is not found in the array, return 0.
  • The ar...read more
Ans.

Count occurrences of a number in a sorted array efficiently.

  • Use binary search to find the first and last occurrence of the target number in the array.

  • Calculate the count of occurrences by subtracting the indices of the last and first occurrences.

  • Handle cases where the target number is not found in the array.

  • Time complexity: O(log(N)), Space complexity: O(1).

Add your answer
right arrow
Are these interview questions helpful?

Q7. Distinct Subsequences Problem Statement

You are given a string 'S' of length 'N' which may include duplicate alphabets. Your goal is to calculate the number of distinct subsequences in the string.

Example:

Inpu...read more
Ans.

Calculate the number of distinct subsequences in a string with possible duplicates.

  • Use dynamic programming to keep track of the count of distinct subsequences for each character in the string.

  • Consider the cases where the current character is included or excluded in the subsequence.

  • Handle duplicates by considering the previous occurrence of the character.

  • Return the count of distinct subsequences modulo 10^9 + 7.

Add your answer
right arrow

Q8. Problem: Search In Rotated Sorted Array

Given a sorted array that has been rotated clockwise by an unknown amount, you need to answer Q queries. Each query is represented by an integer Q[i], and you must determ...read more

Ans.

Search for integers in a rotated sorted array efficiently.

  • Implement binary search to find the target integer in the rotated array.

  • Handle the rotation by checking which side of the array is sorted before performing binary search.

  • Return the index of the target integer if found, else return -1.

  • Time complexity of O(logN) is required for each query.

Add your answer
right arrow
Share interview questions and help millions of jobseekers 🌟
man with laptop

Q9. Rotting Oranges Problem Statement

You are given a grid containing oranges where each cell of the grid can contain one of the three integer values:

  • 0 - representing an empty cell
  • 1 - representing a fresh orange...read more
Ans.

Find the minimum time required to rot all fresh oranges in a grid.

  • Use Breadth First Search (BFS) to simulate the rotting process

  • Track the time taken to rot all oranges and return -1 if any fresh oranges remain

  • Handle edge cases such as no fresh oranges or all oranges already rotten

  • Consider using a queue to efficiently process neighboring oranges

Add your answer
right arrow

Q10. Clone Linked List with Random Pointer Problem Statement

Given a linked list where each node has two pointers: one pointing to the next node and another which can point randomly to any node in the list or null, ...read more

Ans.

Yes, the cloning of a linked list with random pointer can be accomplished without utilizing extra space.

  • Use a hashmap to store the mapping between original nodes and cloned nodes.

  • Iterate through the original linked list to create the cloned linked list by mapping the random pointers using the hashmap.

  • Time complexity of this approach is O(N) where N is the number of nodes in the linked list.

Add your answer
right arrow

Q11. Shortest Path Visiting All Nodes

You are given a connected undirected unweighted graph comprising 'N' nodes and 'M' edges. In this graph, each pair of connected nodes is linked by exactly one undirected edge, a...read more

Ans.

Find the length of the shortest path visiting all nodes in a connected undirected unweighted graph.

  • Use Breadth First Search (BFS) to find the shortest path that visits all nodes at least once.

  • Maintain a bitmask to keep track of visited nodes and their states.

  • Consider all possible permutations of nodes to find the shortest path length.

Add your answer
right arrow

Q12. Find Row With Maximum 1's in a Sorted 2D Matrix

You are provided with a 2D matrix containing only the integers 0 or 1. The matrix has dimensions N x M, and each row is sorted in non-decreasing order. Your objec...read more

Ans.

Find the row with the maximum number of 1's in a sorted 2D matrix.

  • Iterate through each row of the matrix and count the number of 1's in each row.

  • Keep track of the row index with the maximum number of 1's seen so far.

  • Return the index of the row with the maximum number of 1's.

  • If multiple rows have the same number of 1's, return the row with the smallest index.

Add your answer
right arrow

Q13. Amazing Strings Problem Statement

Determine if the third string contains all the characters from both the first and second strings in any order. If so, return "YES"; otherwise, return "NO".

Input:

Line 1: First...read more
Ans.

Check if the third string contains all characters from the first and second strings in any order.

  • Create a frequency map for characters in the first and second strings.

  • Check if all characters in the third string are present in the frequency map.

  • Ensure the count of characters in the third string matches the count in the frequency map.

  • Return 'YES' if all conditions are met, otherwise return 'NO'.

Add your answer
right arrow

Q14. Stock buy and sell with at most 2 transaction

Ans.

Implement a solution to find the maximum profit from buying and selling stocks with at most 2 transactions.

  • Use dynamic programming to keep track of maximum profit at each day with 0, 1, or 2 transactions.

  • Consider the possibility of splitting the transactions into two separate parts.

  • Calculate the maximum profit by iterating through the prices array and updating the maximum profit accordingly.

Add your answer
right arrow

Q15. what is thread ?

Ans.

A thread is a lightweight process that can run concurrently with other threads within the same process.

  • Threads allow for parallel execution of tasks within a single process.

  • Threads share the same memory space and resources of the process they belong to.

  • Threads can communicate with each other through shared memory or message passing.

  • Examples: Java threads, POSIX threads (pthreads) in C/C++.

Add your answer
right arrow

Q16. Binary search to find target

Ans.

Binary search is a divide and conquer algorithm that efficiently finds a target value in a sorted array.

  • Divide the array in half and compare the target value with the middle element

  • If the target is less than the middle element, search the left half. If greater, search the right half

  • Repeat the process until the target is found or the subarray is empty

Add your answer
right arrow

Q17. Design paytm wallet

Ans.

Design a digital wallet system similar to Paytm.

  • Allow users to add money to their wallet using various payment methods like credit/debit cards, net banking, UPI, etc.

  • Enable users to make payments for various services like mobile recharge, bill payments, online shopping, etc.

  • Implement security measures like two-factor authentication, encryption of sensitive data, and regular security audits.

  • Provide features like transaction history, cashback offers, loyalty points, and seamles...read more

Add your answer
right arrow
Contribute & help others!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos

Interview Process at Urban Company Software Developer

based on 5 interviews
1 Interview rounds
Coding Test Round
View more
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

Amazon Logo
4.1
 • 321 Interview Questions
Goibibo Logo
4.3
 • 15 Interview Questions
View all
Recently Viewed
INTERVIEWS
Urban Company
No Interviews
INTERVIEWS
Urban Company
No Interviews
CAMPUS PLACEMENT
College of Engineering, Guindy Campus
INTERVIEWS
Urban Company
10 top interview questions
INTERVIEWS
InMobi
10 top interview questions
INTERVIEWS
Urban Company
No Interviews
INTERVIEWS
InMobi
No Interviews
INTERVIEWS
SKH Metals
No Interviews
INTERVIEWS
Uber
No Interviews
INTERVIEWS
SKH Metals
No Interviews
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter