UBS interview questions

107 questions from 20 interviews · updated from reports 2017-2024

Practise UBS-style

About

UBS is a Swiss bank and financial services firm offering wealth management, asset management, investment banking, and personal and corporate banking. In India, it hires for technology roles such as Software Engineer, IT Software Engineer, and SDE supporting banking platforms and internal systems.

The roles that come up most are Software Engineer, IT Software Engineer and SDE. This covers 20 candidate interviews reported from 2017 to 2024. Most sat it at entry level (17 of 20 that recorded a level), with 3 internship interviews alongside. Among the 18 that recorded either route, arrivals split between campus drives (17, 94%) and off-campus applications (1, 6%). Most questions fall under CS fundamentals and DSA.

Category
Difficulty
Round

Interview questions

Q. Find the length of the longest substring with at most K normal characters.

asked 2xmediumStringsOnline test2020-2021

Ans. Use a sliding window with two pointers and keep a count of normal characters inside the window. Expand the right pointer, increment the count if the character is normal, and while the count exceeds K, move the left pointer and update the count. Track the maximum valid window length. Time complexity is O(n).

Q. Explain the different types of inheritance in Object-Oriented Programming.

asked 2xeasyOOPTechnical2023

Ans. The main types of inheritance are single, multiple, multilevel, hierarchical and hybrid inheritance. Single means one parent class, multiple means several parents, multilevel forms a chain, hierarchical means many child classes share one parent, and hybrid combines patterns. Some languages, such as Java, restrict multiple class inheritance to avoid ambiguity.

Q. Write code related to linked lists

asked 1xmediumLinked listsTechnical2018

Ans. Implement a singly linked list using a Node object with value and next fields, and keep a head pointer to the first node. Insert at the head in constant time, traverse by following next pointers, and delete by relinking the previous node. Traversal and search take O(n) time, with O(1) extra space.

Q. Answer conceptual questions on DBMS

asked 1xmediumDBMSTechnical2018

Ans. A DBMS is software that stores, organises, retrieves and protects data while letting multiple users access it safely. The key ideas are data models, schemas, queries, transactions, concurrency control, indexing and normalisation. In interviews, connect each concept to consistency, performance, integrity or easier data management.

Q. Design a database schema for an App Store.

asked 1xmediumDatabase designTechnical2019

Ans. Use a relational schema with users, developers, apps, app_versions, categories, purchases, downloads, reviews, ratings, devices and payments. Apps belong to developers and categories, versions store binaries, compatibility and release notes, and purchases link users to apps. The key detail is separating app metadata from versioned releases so updates, rollback and audit history remain clean.

Q. Explain B+ trees and indexing in databases

asked 1xmediumDBMSTechnical2022

Ans. A B+ tree is a balanced tree index used by databases to find rows quickly without scanning the whole table. Internal nodes store keys for navigation, while leaf nodes store sorted keys and pointers to records or pages. Because leaves are linked, B+ trees are efficient for both exact lookups and range queries.

Q. Optimize the performance of a given method

asked 1xmediumOptimizationOnline test2021

Ans. Improve the method by reducing its time complexity first, then memory use if needed. Profile or inspect the loops, remove repeated work, cache reusable results, and replace linear searches with a suitable structure such as a hash map or set. State the new complexity, for example reducing nested scans from O(n²) to O(n).

Q. Explain what PL/SQL is and write a trigger.

asked 1xmediumDBMSTechnical2023

Ans. PL/SQL is Oracle’s procedural extension to SQL, used to write stored procedures, functions, packages and triggers inside the database. A trigger can be defined to run before or after an insert, update or delete on a table. For example, before inserting an employee row, set its audit timestamp. This runs per affected row.

Q. How is JSX compiled and converted into JavaScript?

asked 1xmediumFrontendTechnical2022

Ans. JSX is compiled by tools such as Babel or TypeScript into normal JavaScript function calls. In older React this becomes React.createElement calls, while modern React often uses jsx or jsxs runtime calls. The result is plain JavaScript objects describing elements, which React later uses during rendering and reconciliation.

Q. Explain OS concepts such as Paging and Segmentation

asked 1xmediumOperating systemsTechnical2021

Ans. Paging and segmentation are memory management techniques that let an OS map a process’s logical address space to physical memory. Paging divides memory into fixed-size pages and frames, which reduces external fragmentation. Segmentation divides memory into logical variable-size parts, such as code, stack and data, matching the program structure but risking external fragmentation.

Q. How do you find the 3rd highest salary in a database?

asked 1xmediumSQLTechnical2024

Ans. Find the 3rd highest salary by selecting distinct salaries, ordering them descending, and taking the third row. The important detail is using distinct salaries, otherwise duplicate salaries can give the wrong result. In SQL, this is usually done with a limit and offset, or more robustly with DENSE_RANK over salaries ordered descending.

Q. Explain client-side rendering vs server-side rendering

asked 1xmediumWebTechnical2022

Ans. Client-side rendering builds the page in the browser using JavaScript, while server-side rendering builds the initial HTML on the server and sends it ready to display. The key trade-off is that SSR usually gives faster first load and better SEO, while CSR can make later interactions feel smoother after the app loads.

Q. Explain what happens internally when you run a program

asked 1xmediumOperating systemsTechnical2024

Ans. When you run a program, the operating system creates a process and loads the executable into memory. The loader maps code, data, stack, heap and shared libraries into virtual memory, then starts execution at the entry point. The CPU fetches and executes instructions, while the OS handles scheduling, memory protection and system calls.

Q. Given a sequence of words, print all anagrams together

asked 1xmediumStringsTechnical2021

Ans. Group words by a canonical key and print each group. Use a hash map where the key is either the sorted letters of the word or a fixed-size character frequency vector, and the value is the list of matching words. With sorted keys, time is O(n k log k) and space is O(n k).

Q. How do you store and manage images in a web application?

asked 1xmediumWebTechnical2022

Ans. Store images in object storage such as S3, Azure Blob or a file store, and keep only metadata and the image URL in the database. The most important detail is to avoid storing large binaries in the application database; use validation, unique names, access controls, resizing and a CDN for delivery.

Q. Explain inner classes, threads, and synchronization in Java.

asked 1xmediumOOPTechnical2019

Ans. Inner classes are classes defined inside another class, threads are independent paths of execution, and synchronization controls access to shared data between threads. The key detail is that Java threads share heap memory, so mutable shared state must be protected using synchronized blocks, locks, or concurrent utilities to prevent race conditions and visibility bugs.

Q. How can you ensure data security while using cloud services?

asked 1xmediumCloudTechnical2024

Ans. Ensure data security in cloud services by applying strong access control, encryption, secure configuration, monitoring, and regular audits. The most important detail is least privilege access: users, services, and applications should only have the permissions they need, protected with MFA, key management, logging, and prompt removal of unused access.

Q. Write an SQL query to find the highest salary department-wise

asked 1xmediumSQLTechnical2024

Ans. Use an aggregate query that groups rows by department and selects the maximum salary in each group. The key detail is to use GROUP BY on the department column and MAX on the salary column. If department names are stored separately, join the employee and department tables first.

Q. Are you familiar with PL/SQL? Write a trigger and explain its use.

asked 1xmediumDBMSTechnical2023

Ans. Yes, PL/SQL is Oracle’s procedural extension to SQL, and a trigger is a stored block that runs automatically on events such as insert, update or delete. For example, a before update row trigger can validate values or write old and new values to an audit table. It runs once per affected row, with constant trigger overhead.

Q. What happens if an exception occurs in code and it is not handled?

asked 1xmediumOOPTechnical2020

Ans. If an exception occurs and is not handled, it propagates up the call stack until a matching handler is found or the program terminates. The runtime usually prints an error message or stack trace, and any normal flow after the exception is skipped unless cleanup code, such as finally, is defined.

Q. Reverse a string using recursion without using any auxiliary memory

asked 1xmediumRecursionTechnical2020

Ans. Use recursion with two indices, one at the start and one at the end, swapping the characters in place and then recursing inward until the indices meet or cross. This needs a mutable character array, because most strings are immutable. Time complexity is O(n); auxiliary data structures are not used, but recursion uses O(n) call stack.

Q. Design classes and implement constructors to satisfy given test cases.

asked 1xmediumOOPTechnical2021

Ans. Create the minimal set of classes whose public constructors and methods match the tests exactly, then store constructor arguments in private fields and initialise any required defaults. Use simple composition or inheritance only when the tests imply it. Construction is O(1) per object, and later method costs depend on the stored data accessed.

Q. Explain database normalization and the difference between 3NF and BCNF

asked 1xmediumDBMSTechnical2024

Ans. Database normalization is organising tables to reduce duplication and avoid update, insert and delete anomalies. 3NF requires every non-key attribute to depend only on a key, allowing some dependencies where the dependent attribute is prime. BCNF is stricter: for every functional dependency, the determinant must be a candidate key.

Q. Explain differences in architecture between popular backend frameworks

asked 1xmediumBackendTechnical2022

Ans. Backend frameworks mainly differ in how they organise requests, application structure, concurrency and extensibility. Express is minimal and middleware based, Django is batteries included with MVC-style patterns and ORM, Spring Boot uses layered dependency injection, Rails favours convention over configuration, and FastAPI is type-driven and asynchronous. The key difference is flexibility versus built-in structure.

Q. Explain DBMS concepts including Normalization, Joins, and ACID properties

asked 1xmediumDBMSTechnical2021

Ans. A DBMS stores, organises and manages data, while normalisation, joins and ACID help keep it correct and useful. Normalisation reduces duplication by splitting data into related tables. Joins combine rows from tables using keys. ACID means transactions are atomic, consistent, isolated and durable, so database changes remain reliable even during failures.

Q. Design a RESTful API for a given scenario and explain different HTTP methods

asked 1xmediumApi designTechnical2024

Ans. Design resources as nouns, for example /users, /users/{id}, and /users/{id}/orders, using JSON, status codes, pagination, filtering, authentication, and versioning. GET reads, POST creates, PUT replaces, PATCH partially updates, DELETE removes, and OPTIONS describes capabilities. Keep operations stateless, validate input, return meaningful errors, and make unsafe methods idempotent where appropriate.

Q. Give real-life examples explaining the pillars of Object-Oriented Programming.

asked 1xmediumOOPTechnical2024

Ans. Encapsulation is like a car hiding its engine behind pedals, abstraction is driving without knowing engine details, inheritance is an electric car sharing features of a car, and polymorphism is different vehicles responding to “start” differently. The key idea is modelling real things as objects with data and behaviour.

Q. Explain garbage collection in Java and how memory is freed if an exception occurs.

asked 1xmediumOOPTechnical2020

Ans. Garbage collection in Java automatically frees heap memory used by objects that are no longer reachable from live references. If an exception occurs, the stack unwinds; local variables in exited methods disappear, so any objects only referenced there become eligible for collection. The actual freeing happens later, when the garbage collector runs.

Q. Which is better: an abstract class with all abstract methods or an interface? Explain why.

asked 1xmediumOOPTechnical2020

Ans. An interface is usually better if every method is abstract, because it represents a pure contract without implying shared implementation or state. A class can implement multiple interfaces, but usually only extend one class. Use an abstract class instead when you need shared code, fields, constructors, or protected behaviour.

Q. Explain method overriding in Java, including what happens if a base class method is private.

asked 1xmediumOOPTechnical2019

Ans. Method overriding in Java means a subclass provides its own implementation of an inherited instance method with the same signature and compatible return type. Calls are resolved at runtime based on the actual object. A private base class method is not inherited, so it cannot be overridden; a same-named subclass method is separate.

Q. Explain why the String class in Java is immutable and demonstrate how to create an immutable class.

asked 1xmediumOOPTechnical2019

Ans. Java String is immutable so its value cannot change after creation, which makes string pooling, cached hash codes, security-sensitive uses, and thread sharing safe. To create an immutable class, make it final, keep fields private and final, set them only in the constructor, provide no setters, and defensively copy mutable inputs and outputs.

Q. Reverse a substring in a given string only if the substring exactly matches; otherwise return an error

asked 1xmediumStringsTechnical2024

Ans. Find the target substring in the string, and only if a full exact match is found, replace that matched range with its reverse; otherwise return an error. Use string search, then a character array or string builder to rebuild the result. With standard search, time is typically O(n + m) or O(nm) depending on implementation.

Q. In a scenario where you are leading a team that is not responding well, how would you handle the situation?

asked 1xmediumLeadershipHR2023

Ans. Choose a real example where team resistance had a clear cause, such as unclear goals, low trust, overload, or disagreement. Emphasise listening first, diagnosing the issue, adapting your leadership style, setting clear expectations, and following up. Interviewers listen for self-awareness, accountability, communication, empathy, and evidence that performance improved.

Q. How would you approach building a system to predict a person's mood based on the type of songs they listen to?

asked 1xmediumMachine learningTechnical2017

Ans. I would build it as a probabilistic recommendation-style model that maps listening behaviour and song features to mood labels. The key detail is getting reliable consented training data, because mood is subjective. Use audio features, lyrics, genre, tempo, time, skips, repeats and user feedback, then serve predictions with confidence scores and regular retraining.

Q. Given a linked list where the number of nodes is unknown, solve the problem using a pointer-based solution in one pass

asked 1xmediumLinked listsTechnical2024

Ans. Use two pointers: a slow pointer moving one node at a time and a fast pointer moving two nodes at a time. When the fast pointer reaches the end, the slow pointer is at the middle. This works without knowing the length, uses constant extra space, and runs in O(n) time.

Q. Given multiple database tables, perform JOIN operations to derive the desired output for specific test case scenarios.

asked 1xmediumDBMSTechnical2023

Ans. Join the tables on their shared primary and foreign keys, selecting the columns required by the test case and applying filters only where they match the expected scenario. Use INNER JOIN when only matching rows are needed, LEFT JOIN when unmatched left-side rows must remain, and verify duplicates caused by one-to-many relationships.

Q. Write an SQL query to display the author and the number of books written by them from a table having multivalued attributes.

asked 1xmediumSQLTechnical2023

Ans. Use a GROUP BY query on the author column and count the book values for each author. In SQL terms, select author and COUNT(book_id or book_name) from the table, then group by author. The key detail is that multivalued attributes should ideally be normalised into separate rows before counting.

Q. Explain JavaScript closures and predict the output of a function using closures (e.g., function ex(temp) { return [temp]; }).

asked 1xmediumProgramming languagesTechnical2020

Ans. A JavaScript closure is when an inner function keeps access to variables from its outer function after the outer function has finished. The important point is that it captures the variable, not just its current-looking scope. For function ex(temp) returning an array containing temp, calling it with 5 returns an array with 5.

Q. 100 Doors Puzzle: There are 100 doors initially closed. After 100 passes toggling doors at multiples, which doors remain open?

asked 1xmediumLogical reasoningOnline test2017

Ans. The open doors are 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100. A door is toggled once for each divisor of its number. Most numbers have divisors in pairs, so they end closed. Perfect squares have one unpaired divisor, the square root, so they are toggled an odd number of times.

Q. Explain the String class in Java and discuss collections like HashMap and Hashtable, including differences between HashMap and Hashtable.

asked 1xmediumOOPTechnical2019

Ans. String in Java is an immutable sequence of characters, so operations create new objects and string literals are stored in the string pool. HashMap and Hashtable store key value pairs using hashing. HashMap is not synchronised, allows one null key and null values, and is generally preferred. Hashtable is synchronised, legacy, and does not allow null keys or values.

Q. If you were the new employee unfamiliar with the tech stack and facing issues implementing a feature, how would you handle the situation?

asked 1xmediumTeamworkTechnical2023

Ans. Pick a situation where you were new, unblocked yourself, and still delivered responsibly. Emphasise reading documentation, reproducing the issue, isolating what you did not understand, asking specific questions, and pairing with experienced teammates. Interviewers listen for humility, structured learning, ownership, communication, and avoiding wasted time without becoming dependent.

Q. Given a string and a vector of strings, find the lexicographically smallest string that can be formed by rearranging the characters of the given string.

asked 1xmediumStringsOnline test2023

Ans. Return the smallest string in the vector whose character multiset exactly matches the given string’s character multiset. Count the characters of the given string, then for each candidate with the same length count its characters and compare. Keep the lexicographically smallest valid candidate. Time is O(total characters), with O(alphabet size) extra space.

Q. Given a string and a vector of strings, find the lexicographically smallest string that can be created by rearranging the characters of the given string.

asked 1xmediumStringsOnline test2023

Ans. Count the characters of the given string, then scan the vector and keep the lexicographically smallest string whose character counts exactly match it. Use a fixed-size frequency array for each word, assuming a known alphabet such as lowercase letters. The time complexity is O(n + total characters in the vector), with O(1) extra space.

Q. As a technical head, how would you handle a situation where a new employee is struggling to implement a feature due to lack of familiarity with the tech stack?

asked 1xmediumLeadershipTechnical2023

Ans. Pick a real example where you supported someone without taking over. Emphasise early diagnosis, a calm one-to-one, pairing, documentation, small milestones, and clear expectations. Show you protected delivery while helping the employee learn. Interviewers listen for patience, ownership, coaching skill, and the ability to balance people development with project commitments.

Q. Four people with crossing times 1, 2, 7, and 10 need to cross a river with one torch; only two can cross at a time and one must return. Find the minimum total time.

asked 1xmediumLogical reasoningTechnical2020

Ans. Minimum total time is 17 minutes. Send the two fastest first: 1 and 2 cross in 2, then 1 returns. Send the two slowest together: 7 and 10 cross in 10, then 2 returns. Finally, 1 and 2 cross again in 2. Total: 2 + 1 + 10 + 2 + 2 = 17.

Q. Given a string s, remove duplicate letters so that every letter appears once and the resulting string is the smallest in lexicographical order among all possible results.

asked 1xmediumStackOnline test2023

Ans. Use a monotonic stack to build the smallest lexicographical result while keeping each character once. Store each character’s last index, then scan the string. If a character is not already used, pop larger stack characters that appear again later, then push it. Track used characters with a set. This is O(n) time and O(1) extra space for lowercase letters.

Q. Given a movement string consisting of 'C' (clockwise), 'A' (anticlockwise), and '?' (unknown), determine the maximum possible displacement from the origin by replacing '?' optimally.

asked 1xmediumStringsOnline test2019

Ans. The maximum possible displacement is abs(countC minus countA) plus countQuestionMarks. Count clockwise moves as +1, anticlockwise moves as -1, and each unknown can be chosen to increase the final absolute displacement. So replace all '?' in the direction that already has the larger net count. This takes linear time and constant space.

Q. Given an array where each element represents the time taken by a task, allocate tasks to n persons such that each person gets nearly equal total work. Tasks must be assigned in sequence.

asked 1xmediumArraysTechnical2017

Ans. Minimise the maximum total time assigned to any person, with each person receiving a contiguous block of tasks. Use binary search on the possible maximum workload, from the largest single task to the total sum. For each guess, greedily form blocks until exceeding it. If more than n persons are needed, increase it. Time is O(m log sum).

Q. Given a string consisting of characters 'A', 'C', and '?', where 'A' means anti-clockwise move, 'C' means clockwise move, and '?' can be replaced by either 'A' or 'C', determine how to replace '?' to achieve the maximum distance from the initial position after traversing the entire string.

asked 1xmediumStringsOnline test2019

Ans. Replace every '?' with the direction that increases the larger existing count: use 'C' if there are at least as many 'C' moves as 'A', otherwise use 'A'. The final maximum distance from the start is abs(countC minus countA) plus countQuestionMarks, because distance depends only on the net clockwise versus anti-clockwise moves.

Q. Matrix Traversal: Given a 4x4 matrix with initial energy 100, start from any cell in the first row and move to (i+1,j-1), (i+1,j), or (i+1,j+1) in each step until the last row. Energy decreases by the value of each visited cell. Find the maximum possible energy left at the end (energy can be negative).

asked 1xmediumDynamic programmingOnline test2021

Ans. The maximum energy left is 100 minus the minimum valid path sum from the first row to the last row. Use dynamic programming where dp[i][j] is the minimum energy cost to reach cell i,j. Transition from the three allowed cells above it, then take the minimum in the last row. Time complexity is O(16), generally O(nm).

Q. Count the minimum number of fountains to be activated to cover the entire garden

asked 1xhardGreedyTechnical2021

Ans. Convert each fountain into a coverage interval and greedily choose the fewest intervals that extend coverage farthest. For fountain i, store the maximum right end for its left end. Scan the garden, maintaining current coverage and farthest reach; when current coverage ends, activate one fountain. This takes O(n) time and O(n) space.

Q. 100 prisoners with red/black hats puzzle: Devise a strategy so that the maximum number of prisoners can guess their hat color correctly.

asked 1xhardLogical reasoningOnline test2017

Ans. Agree that the first prisoner says “red” if he sees an odd number of red hats, otherwise “black”. This encodes parity. Each later prisoner counts the red hats ahead and compares with the parity, adjusting for previous answers. They can deduce their own colour exactly. Thus 99 are guaranteed correct, and the first may be wrong.

Q. Given an array, preprocess it using prefix sums and answer multiple queries efficiently using binary search such that brute-force approaches lead to TLE.

asked 1xhardArraysOnline test2024

Ans. Build a prefix sum array once, where pref[i] stores the sum up to index i, then answer each query by binary searching on this prefix array for the required cumulative value or boundary. This avoids scanning the array per query. Preprocessing takes O(n), each query takes O(log n), and space is O(n).

Q. Given an array representing the capacity of each machine, find the maximum network size such that each member in the network is adjacent, satisfies a minimum size, and meets a minimum threshold.

asked 1xhardArraysTechnical2020

Ans. The maximum network size is found by treating each capacity as the bottleneck and taking the widest contiguous segment where all machines meet it. Use a monotonic increasing stack to find previous and next smaller capacities, compute each span, and keep the largest span with size at least minimum and capacity times span meeting the threshold. Time is O(n).

Q. Compare C++ and Java

asked 1xeasyProgramming languagesTechnical2024

Ans. C++ is a compiled language with manual memory control and close-to-hardware performance, while Java runs on the JVM with automatic garbage collection and stronger portability. The most important difference is control versus safety: C++ gives more control over memory and resources, but Java is usually simpler, safer and easier to deploy across platforms.

Q. Explain the core OOP concepts in Java

asked 1xeasyOOPTechnical2020

Ans. The core OOP concepts in Java are encapsulation, abstraction, inheritance and polymorphism. Encapsulation keeps data and behaviour together and controls access with modifiers. Abstraction exposes essential behaviour through interfaces or abstract classes. Inheritance reuses and extends classes. Polymorphism lets the same method call behave differently through overriding or interface implementations.

Q. Implement a function to reverse a string

asked 1xeasyStringsTechnical2020

Ans. Use two pointers to swap characters from the start and end until they meet. If strings are immutable, first copy the string into a character array, perform the swaps in place, then build the result. This uses constant extra space for mutable arrays and runs in O(n) time.

Q. Explain the four pillars of Object-Oriented Programming

asked 1xeasyOOPTechnical2024

Ans. The four pillars of object-oriented programming are encapsulation, abstraction, inheritance, and polymorphism. Encapsulation hides internal state behind methods. Abstraction exposes only essential behaviour. Inheritance lets classes reuse and extend other classes. Polymorphism lets different objects be treated through the same interface while providing their own behaviour.

Q. Write code to check whether a given number is a palindrome

asked 1xeasyMathTechnical2020

Ans. A number is a palindrome if it reads the same forwards and backwards. Handle negatives as not palindromes, then reverse the digits numerically, or reverse only half to avoid overflow, and compare with the original or remaining half. No data structure is needed. Time complexity is O(d), space complexity is O(1), where d is digit count.

Q. Quantitative aptitude problem involving clock losing 2 minutes every hour.

asked 1xeasyLogical reasoningOnline test2019

Ans. A clock losing 2 minutes every hour runs 58 minutes for every 60 minutes of real time. Treat its rate as 58/60 of the correct clock. Convert any shown time difference using this ratio: real time = clock time × 60/58. If comparing with a correct clock, use the 2 minutes per hour loss as the relative drift.

Showing 60 of 107 questions. Ranked by how often the same question came back across interviews.

Practise an UBS-style interview

A spoken interview built from these questions, scored when you finish; the feedback is yours.

Start practising

When you are ready, record The One: a single interview hiring teams watch, so you stop repeating first rounds.

Common questions

What questions does UBS ask?

Candidate interviews most often cover CS fundamentals (61%) and DSA (25%).

How many rounds does UBS interview have?

Candidate interviews show an average of 3.3 rounds per experience, with a typical sequence of Online test → Technical → HR. Individual interview paths can vary.

Is the UBS interview hard?

Among questions with a recorded difficulty, the mix is easy 50%, medium 45%, hard 5%.