UBS Previous Year Coding Questions and Hiring Process
UBS runs a large technology center in India out of Pune, Mumbai, and Hyderabad, and hires freshers every year for Technology Analyst and Graduate Trainee roles through its Graduate Talent Program, alongside standard campus and off campus drives. It recruits from B.E./B.Tech backgrounds and the process leans heavily on a HackerRank based online assessment.
If you are preparing for UBS, understanding the assessment structure, the two round technical interview, and the company knowledge expected in the HR round will help you prepare efficiently. This guide covers the complete UBS hiring process along with previous year coding questions asked in its online assessments and interviews.
UBS Hiring Process
Here is the typical flow for UBS fresher hiring through campus and off campus drives. Exact formats vary somewhat by year and campus, so treat these as representative rather than fixed.
| Stage | What Happens | What They Are Looking For |
|---|---|---|
| A HackerRank based test, around 60 to 75 minutes, mixing MCQs on aptitude and CS fundamentals with one to two coding problems ranging from easy to medium hard. | Breadth across fundamentals and working code under time pressure. |
| A resume and project walkthrough alongside DSA questions and OOP fundamentals, sometimes with live coding on HackerRank CodePair. | Ability to explain your own code and design choices. |
| Deeper DSA, SQL and DBMS questions, operating systems fundamentals, and sometimes backend or API related questions depending on your project background. | Depth across core CS subjects, not just DSA. |
| A conversation about your background, willingness to relocate to Pune, Mumbai, or Hyderabad, and what you know about UBS as a company. | Genuine interest and cultural fit. |
Selection funnels at UBS are steep, with some drives reporting several thousand applicants narrowing down to a few dozen offers, so treat every stage as competitive rather than assuming the interviews are a formality once you clear the OA.
Assessment Pattern
Format: A HackerRank based proctored online test, generally completed in one sitting.
Sections typically included:
- Aptitude and Logical Reasoning: Quantitative and logical reasoning questions.
- Technical MCQs: DSA, SQL or DBMS, operating systems, and Java or OOP fundamentals.
- Coding Round: One to two problems, easy to medium hard difficulty.
UBS Coding Round: What to Expect
The coding round at UBS mixes standard DSA problems with a few distinctive simulation and optimisation style questions. Frequently reported topics include:
- String manipulation problems such as reversing substrings or removing duplicate letters for the smallest lexicographic result
- Array and matrix traversal problems, including maximizing a resource while moving through a grid
- Linked list problems such as converting a binary valued list to its decimal equivalent
- Greedy and simulation style problems, such as covering a garden with the minimum number of fountains
- Classic data structure problems such as implementing a stack that also tracks its minimum element
For hands on practice, use:
Technical Interview Focus Areas
Real questions reported by candidates in the technical interview rounds:
- Write a SQL query to find the department wise highest salary of an employee without using aggregate functions.
- Write a SQL query to find the third highest salary in a table.
- Write a SQL query to extract the name and email of the employee with the maximum age.
- Explain the difference between third normal form and Boyce-Codd normal form.
- Difference between abstract classes and interfaces.
- Static versus dynamic polymorphism, meaning compile time versus runtime.
- Encapsulation versus abstraction, with real life examples.
- Function overloading versus overriding, with real life examples.
- What are the advantages of using a HashMap.
- Explain garbage collection in Java and how exception handling interacts with memory.
- Mutable versus immutable classes, static classes, and how multiple catch blocks behave.
- Explain interfaces in Java, and the four pillars of object oriented programming with real life examples.
- Explain in detail what happens when you run a program.
- Describe your experience with multithreading, and what data structures the operating system uses.
- Explain B+ trees and database indexing, applied to your own project.
- Client side versus server side rendering, how JSX compiles, and the difference between APIs and web services.
- Explain string immutability in Java, illustrated using the trim method.
- What is a deadlock in operating systems, and what are the necessary conditions for one to occur.
- Difference between paging and segmentation.
- What is a zombie process in Linux.
HR Interview Tips
The HR round checks communication, motivation, and how much you know about UBS as a company. Common questions include:
- Tell me something about yourself.
- Why do you want to join UBS.
- Tell me about your family background.
- Are you willing to relocate to Pune, Mumbai, or Hyderabad.
- What do you know about UBS, including basic facts like the significance of the three keys in its logo.
- What would be the role of an engineer inside an investment bank.
- What do you know about UBS's recent acquisition of Credit Suisse.
- How would you handle a new team member who is struggling with an unfamiliar tech stack.
- Describe a challenging project you worked on, and what you expect from this role.
Complete HR Interview Questions
Spend a little time reading about UBS's business and its recent history before the interview, company knowledge questions come up more often here than at many other companies.
Resources to Prepare for UBS
- Free Aptitude Mock Practice latest patterns and mock tests
- ATS Score Checker and Resume Optimizer
- Roadmaps
- Interview Questions
- Resume Templates
- Free Placement Materials (Google Drive)
- Interview Experience
UBS Previous Year Coding Questions
Below is a list of UBS previous year coding questions commonly reported by candidates in the online assessment and technical interview. Each question includes a problem statement, input and output format, and a sample explanation.
1. Count Character Types in a Sentence
Problem Statement: Given a sentence, count the number of lowercase letters, uppercase letters, digits, and special characters in it.
Input Format:
- A string
s
Output Format:
- The counts of lowercase, uppercase, digit, and special characters
Example:
Input: Hello World 123!
Output: Lowercase = 8, Uppercase = 2, Digits = 3, Special = 2
2. Reverse a Substring Within a String
Problem Statement: Given a string and a substring to locate within it, reverse only that substring in place, leaving the rest of the string unchanged. If the substring is not found, return an error.
Input Format:
- A string
sand a substringpart
Output Format:
- The modified string, or
"error"if the substring is not found
Example:
Input: s = "HELLO WORLD", part = "HELLO"
Output: OLLEH WORLD
3. Longest Substring With At Most K Special Characters
Problem Statement: Given a string and an integer K, find the length of the longest substring that contains at most K characters from a defined "special" set.
Input Format:
- A string
sand an integerk
Output Format:
- The length of the longest valid substring
Example:
Input: s = "a#b#c#d", k = 1
Output: 3
4. Maximize Energy Traversing a Matrix
Problem Statement: Given a matrix where each cell either adds to or subtracts from your energy, starting with a fixed energy value at the top, find the maximum energy you can have left after reaching the last row, moving only downward or diagonally.
Input Format:
- A matrix of energy changes and a starting energy value
Output Format:
- The maximum energy remaining after reaching the last row
Example:
Input: matrix = [[-2,3,1,-4],...], startEnergy = 100
Output: the maximum energy value achievable
5. Remove Duplicate Letters for Smallest Result
Problem Statement: Given a string, remove duplicate letters so each letter appears exactly once, and arrange the result so it is the smallest possible in lexicographic order while keeping the relative order of first appearances.
Input Format:
- A string
s
Output Format:
- The smallest lexicographic string with each letter appearing once
Example:
Input: cbacdcbc
Output: acdb
6. Maximum Displacement on a Circle
Problem Statement: Given a sequence of moves where each move is clockwise, anticlockwise, or unknown, find the maximum possible displacement from the starting point on a circular track, choosing the direction of unknown moves optimally.
Input Format:
- A string of moves containing 'C', 'A', or '?'
Output Format:
- The maximum possible displacement
Example:
Input: C?A?
Output: 2
7. Minimum Fountains to Cover a Garden
Problem Statement: Given a garden represented as a line of positions, and a fountain at each position with a coverage range, find the minimum number of fountains needed to cover the entire garden.
Input Format:
- An integer
nrepresenting the garden length and an arrayrangefor each fountain's reach
Output Format:
- The minimum number of fountains needed, or -1 if the garden cannot be fully covered
Example:
Input: n = 5, range = [1,2,1,2,1]
Output: 2
8. Convert a Binary Linked List to Decimal
Problem Statement: Given the head of a linked list where each node contains either a 0 or a 1, representing a binary number from most significant to least significant bit, return its decimal value.
Input Format:
- A linked list
headof 0s and 1s
Output Format:
- The decimal value represented by the list
Example:
Input: 1 -> 0 -> 1
Output: 5
9. Lexicographically Smallest String From a List
Problem Statement: Given a base string and a list of candidate strings, find the lexicographically smallest string that can be formed by comparing the base string against every candidate.
Input Format:
- A base string and an array of candidate strings
Output Format:
- The lexicographically smallest resulting string
Example:
Input: base = "abc", candidates = ["abd", "aac", "abc"]
Output: aac
10. Task Allotment Among N People
Problem Statement: Given an array of task durations and a number of people, distribute the tasks among the people in sequence so that each person's total workload is as close to equal as possible.
Input Format:
- An array of task durations and an integer
nrepresenting the number of people
Output Format:
- The total workload assigned to each person
Example:
Input: tasks = [3,1,4,1,5,9], n = 3
Output: Person 1 = 4, Person 2 = 5, Person 3 = 14
11. Find the Nth Node From the End of a Linked List
Problem Statement: Given the head of a linked list and an integer N, find the Nth node from the end of the list in a single pass, without first computing the length of the list.
Input Format:
- A linked list
headand an integern
Output Format:
- The value of the Nth node from the end
Example:
Input: 1 -> 2 -> 3 -> 4 -> 5, n = 2
Output: 4
12. Print All Anagrams Together
Problem Statement: Given an array of words, group all anagrams together.
Input Format:
- An array of strings
Output Format:
- The words grouped into lists of anagrams
Example:
Input: ["eat", "tea", "tan", "ate", "nat", "bat"]
Output: [["eat","tea","ate"], ["tan","nat"], ["bat"]]
13. Remove Duplicates From a Linked List
Problem Statement: Given the head of a sorted linked list, remove all duplicate values so each element appears only once.
Input Format:
- A sorted linked list
head
Output Format:
- The list with duplicates removed
Example:
Input: 1 -> 1 -> 2 -> 3 -> 3
Output: 1 -> 2 -> 3
14. Reverse a String Three Ways
Problem Statement: Given a string, reverse it using three different approaches, iteratively, recursively, and without using any auxiliary array or extra memory.
Input Format:
- A string
s
Output Format:
- The reversed string, produced by each of the three approaches
Example:
Input: hello
Output: olleh
15. Check if a Number Is a Palindrome
Problem Statement: Given an integer, determine whether it reads the same forwards and backwards, without converting it to a string.
Input Format:
- An integer
n
Output Format:
"Palindrome"or"Not Palindrome"
Example:
Input: 12321
Output: Palindrome
16. Find the Peak Element in an Array
Problem Statement: Given an array, find a peak element, one that is greater than or equal to its neighbours, in logarithmic time.
Input Format:
- An integer array
arr
Output Format:
- The index of a peak element
Example:
Input: [1, 2, 3, 1]
Output: 2
17. Diameter of a Binary Tree
Problem Statement: Given a binary tree, find the length of its diameter, the longest path between any two nodes, measured in number of edges.
Input Format:
- A binary tree
root
Output Format:
- The diameter of the tree
Example:
Input: root = [1,2,3,4,5]
Output: 3
18. Implement a Min Stack
Problem Statement: Design a stack that supports push, pop, top, and retrieving the minimum element, all in constant time.
Input Format:
- A sequence of push, pop, top, and getMin operations
Output Format:
- The result of each getMin call
Example:
Input: push(-2), push(0), push(-3), getMin(), pop(), top(), getMin()
Output: -3, 0, -2
19. Validate an IP Address
Problem Statement: Given a string, determine whether it represents a valid IPv4 address, with four numbers between 0 and 255 separated by dots, and no leading zeros.
Input Format:
- A string
s
Output Format:
"Valid"or"Invalid"
Example:
Input: 192.168.1.1
Output: Valid
At Last
UBS blends everyday DSA with a handful of distinctive simulation and optimisation style problems, so do not assume every question will look like a textbook LeetCode problem. Revise SQL queries thoroughly since they appear in nearly every technical round, brush up on core OOP and OS fundamentals, and spend some time understanding UBS as a business before your HR round, since company knowledge questions come up more here than at most companies.
Join the Telegram group for more resources and discussions.