InterviewLegend

Easy Problems & Java Follow-ups

Alex Chen35 min readGuide updated
In this lesson
  • Solve Same Tree and Valid Parentheses fast, then list the edge cases unprompted
  • Take a change request on your own code and prove it with JUnit regression tests
  • Answer the Java questions on collections, type erasure, exceptions and functional interfaces
  • Write element frequencies with streams and move zeros in place, as asked in 2025

A recent Deutsche Bank onsite was light on algorithms and heavy on everything around them. It was an August 2025 Software Engineer loop with two technical rounds of an hour each with two interviewers. Each round gave one LeetCode-easy problem. Same Tree came up in one and Valid Parentheses in the other. Once the code worked, the candidate wrote normal and edge test cases.

The candidate wrote Java, and that shaped the rest of the hour. There was no second problem. The interviewers asked for changes to the code on the screen, then moved on to large inputs, Java collections, generics and type erasure, checked and unchecked exceptions, and JUnit. Below are both problems, a change request like the ones they asked for, and the Java answers to have ready. The lesson closes with a 2025 Associate Java round that asked for element frequencies with streams and for moving zeros in place.

The Deutsche Bank angle
Solve the easy problem quickly and cleanly, and most of the hour is left for tests and change requests. Write the tests before anyone asks. Pick your collections on purpose. In that onsite the interviewers asked why each one was there.

How the Deutsche Bank technical interview runs

Expect your round to differ in the details, but the shape is this. You get a short problem and solve it in the language you chose. Then you list test cases, ordinary ones first and the edges after. For two trees that means two empty trees, one empty tree, and equal values in a different shape. For a bracket string it means the empty string, a lone closing bracket and openers that never close.

From there the hour depends on your language. For the Java candidate, every follow-up grew out of the code they had just written: change it for a new rule, say how it copes with huge inputs, justify each collection. The language questions came after that, and the JUnit part included regression tests for the change.

A third round was billed as behavioural and turned out to be mostly technical. It went through past projects and debugging, and asked whether and how the candidate uses AI tools. Prepare that as a topic. Nothing suggests AI help is allowed during the live coding itself, so plan to code without it.

Write code you'd be happy to change. Use clear names and one small helper per idea, and skip the clever one-liners. The second half of the hour is spent editing that code in front of two people, and tidy code turns each change request into a two-line edit.

Asked at Deutsche Bank

Both problems come from that August 2025 onsite, and each was the only problem in its round. The runnable versions below are something like what was asked. Each walkthrough ends with the JUnit tests you'd write next, since the tests were part of the round. Tree inputs are level-order arrays with null for a missing child.

Same Tree

1

Same Tree

EasyCommonly asked
Problem
Given two binary trees, return true if they are the same tree and false otherwise. Two trees are the same when they have the same shape and every pair of matching nodes holds the same value.

Each tree arrives as a level-order array with null for a missing child, so [1,null,2] is a root of 1 with only a right child of 2. Build both trees from their arrays, then compare them. An empty array is an empty tree.
Inputfirst = [1,2,3]second = [1,2,3]Outputtrue

Same shape, and the same value at every position.

How this uses the pattern

Compare the two roots, then recurse on the left pair and the right pair. Two missing nodes match. One missing node, or two values that differ, ends it with false.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Same Tree

Loading...
Click "Run" to execute your code
The Deutsche Bank angle
This was one of the two problems in the August 2025 onsite, and it was the only problem in its round. The algorithm takes a few minutes, so most of your chance to stand out comes after it. Say your base cases out loud before you code them, since the null handling is where a rushed version breaks. Then list tests without being asked: two empty trees, one empty tree, equal values in a different shape and a single leaf that differs. In Java, be ready to say why an Integer value compared with == would break this.
Take it further
Very deep trees. The onsite asked how the code copes with large inputs, and for this problem the answer is depth. A tree shaped like a linked list with a few hundred thousand nodes makes the recursion as deep as the tree. That can throw a StackOverflowError in Java, and Python stops at its recursion limit of about a thousand frames. Keep an explicit stack of node pairs and loop instead. Worked through below.

Valid Parentheses

2

Valid Parentheses

EasyCommonly asked
Problem
Given a string made only of the characters ()[]{}, return true if its brackets are valid and false otherwise.

A string is valid when every opening bracket is closed by a bracket of the same kind, and brackets close in the right order, so the most recently opened one closes first. Every closing bracket needs an opening bracket before it. The empty string is valid.
Inputtext = "()[]{}"Outputtrue

Each pair opens and closes before the next one starts.

How this uses the pattern

Push each opening bracket on a stack. A closing bracket must match the top of the stack, which you pop. At the end the stack must be empty.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Valid Parentheses

Loading...
Click "Run" to execute your code
The Deutsche Bank angle
This was the other easy problem in the same August 2025 onsite, again the only problem in its round. The stack answer is standard, so speed is assumed and the tests are where you stand out. The useful edges are the empty string, a lone closing bracket and openers that never close, like ((. In Java the collection is a natural question. Use ArrayDeque as the stack and say why. Stack extends Vector and synchronizes every call, and its own Javadoc recommends Deque instead.
Take it further
Change the requirement. The next problem is a change request on this exact code, of the kind the onsite's Java rounds were built on. The string now holds ordinary text around the brackets, and you return where the brackets break instead of a yes or no. Try it on your own solution before you read it.

Change requests on your own code

Once the code passed, the interviewers asked for a change to meet a new requirement, then for regression tests. The exact change wasn't given, so practise one of the kind they like. Something like: the bracket checker now runs over real source text, has to skip every other character, and must report the index of the first error so a person can fix it.

The smallest edit wins. Push indexes onto the stack instead of characters, add one branch that skips anything that isn't a bracket, and return the bad closer's index, or the earliest index still open at the end. Say which lines change before you type. Then keep every old test: a valid string should now return -1, and that's your regression check.

Don't rewrite the method. Starting over throws away code that already passed its tests, and it makes the regression tests harder to argue for. A small, named diff is what a reviewer wants from a change request.

The Java questions around your code

The rest of each onsite round went on Java itself. Keep the answers short and tie each one back to the code on the screen. These are the topics the interviewers covered, with the answer you want to give.

Which collection, and why? The bracket stack wants ArrayDeque behind the Deque interface. A closer-to-opener lookup is a HashMap or Map.of. Counts in first-seen order need LinkedHashMap, and sorted keys need TreeMap, which pays O(log n) per operation for the ordering. Name the cost you're trading every time.

Generics and type erasure. Generic types are checked at compile time and erased at runtime, so List and List share one runtime class. That's why you can't write new T(), new T[n] or instanceof List. Two overloads that differ only in a type argument won't compile either, because they erase to the same signature. Type arguments must be objects, so a Map boxes every key and count.

Checked or unchecked exceptions? Checked exceptions such as IOException must be caught or declared, and they suit failures a caller can plan for. Unchecked ones extend RuntimeException and usually mean a bug. IllegalArgumentException for bad input is one, and so is the NoSuchElementException that ArrayDeque.pop() throws on an empty deque. Never catch one only to swallow it, since the failure then disappears without a trace.

JUnit. One behaviour per test, a name that reads as a sentence, and assertEquals(expected, actual) in that order. For a change request, keep the old tests and add new ones for the new rule. The old tests passing again is the regression check. @ParameterizedTest keeps a long list of edge cases short.

The Associate Java backend round (2025)

An August 2025 Associate Java backend interview in Pune, for a candidate with three years of experience, had a different mix. The first round ran on Microsoft Teams. It worked through a long list of Java 8, Spring, REST and testing questions, with two small coding tasks inside it. The candidate was selected and told the second round would be face to face in the office.

Element frequencies with streams

3

Element Frequencies With Streams

EasySometimes asked
Problem
Given a list of integers, return how often each value appears. Return a list of [value, count] pairs in the order each value first appears.

An empty list returns an empty list. Values can be negative or zero.
Inputnumbers = [1,2,2,3,3,3]Output[[1,1],[2,2],[3,3]]

Each value is listed once, with its count.

How this uses the pattern

Count into a map that remembers insertion order, then turn each entry into a pair.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Element Frequencies With Streams

Loading...
Click "Run" to execute your code
The Deutsche Bank angle
The August 2025 Teams round asked for this with Java streams, so it's a quick test of whether you know the collectors. The standard stream answer is groupingBy with Collectors.counting(). Two details are worth saying out loud. A plain groupingBy makes no promise about order, so pass a LinkedHashMap constructor as the map factory when order matters. And counting() produces a Long, so the map is a Map. Starting from an int[], you need .boxed() before you can collect.
Take it further
Most frequent first. A natural next ask is to list the values by count, highest first, with ties broken by value. Sort the entries with a Comparator built from Map.Entry.comparingByValue().reversed(), then thenComparing(Map.Entry.comparingByKey()). The same round asked about Comparator as a functional interface, so expect to explain that line. Worked through below.

Move zeros to the end in place

4

Move Zeroes In Place

EasySometimes asked
Problem
Given an array of integers, move every 0 to the end while the other values keep their original order. Do it by changing the array itself, with no second array.

Return the same array once it's rearranged, so the tests can check it.
Inputnumbers = [0,1,0,3,12]Output[1,3,12,0,0]

The non-zero values keep their order, and both zeros move to the end.

How this uses the pattern

Keep a write index for where the next non-zero value belongs. Scan with a read index and swap each non-zero value back to the write index.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Move Zeroes In Place

Loading...
Click "Run" to execute your code
The Deutsche Bank angle
This was the array problem in the same August 2025 Teams round, asked in plain words: zeros to the back, the other numbers to the front in order, in the same array. It's easy, so the in-place rule is the real test, and building a second list breaks it. Say the invariant as you code. Everything before the write index is a non-zero value in its original order. In Java, assertArrayEquals is the JUnit check, since assertEquals on two arrays compares references.
Take it further
Fewer writes. The swap version writes even when a value is already in place, as in an array with no zeros at all. Swap only when the read and write indexes differ. The other approach is two passes: copy the non-zero values forward, then fill the rest with zeros. Both are O(n), so say which one writes less for the input you expect. Worked through below.

The Java 8 questions in that round

The same 2025 round ran through a list of Java 8 questions around the two coding tasks. One asked for the return type of Predicate. Another, in the candidate's words, was "Why comparable is not functional interface when comparator is". Both have short, exact answers.

What is a functional interface? An interface with exactly one abstract method, so a lambda or a method reference can stand in for it. Default and static methods don't count, and neither do methods that Object already declares. @FunctionalInterface is optional, but with it the compiler rejects a second abstract method.

What does Predicate return? Predicate has one abstract method, boolean test(T t), so it returns a primitive boolean. The neighbours are worth naming too. Function maps a value to a result, Consumer returns nothing, and Supplier takes nothing.

Why is Comparator a functional interface when Comparable isn't? Comparator is annotated @FunctionalInterface. It declares equals as well as compare, but equals comes from Object, so compare is its one abstract method. Comparable also has a single abstract method, compareTo, and a lambda would compile against it. It carries no annotation because a class implements it on itself, comparing this with another object. A lambda sits outside the objects it compares, which is exactly what Comparator describes.

Common questions

What coding questions does Deutsche Bank ask in the technical interview?

An August 2025 onsite gave one LeetCode-easy problem an hour (Same Tree in one round, Valid Parentheses in the other), followed by test cases and follow-ups on the code. A 2025 Associate Java round asked for element frequencies with streams and for moving zeros in place. Older rounds lean on classics like linked lists, sorting and SQL, and each has its own lesson in this guide.

What are Deutsche Bank Java developer interview questions like?

Practical and close to the code. Expect to change your own solution for a new requirement and defend your collection choices. Generics and type erasure come up, along with checked versus unchecked exceptions and JUnit tests for the change. The 2025 backend round added streams, functional interfaces, Predicate and the Comparable versus Comparator question.

Do I have to code in Java?

No. You choose your language in the online test and the live rounds, and candidates have used C++ and Python too. Java is where the follow-ups go when you pick it, so only choose it if you can answer the questions in this lesson without notes.

Can I use AI tools in the coding round?

Assume not. The only AI rule on Deutsche Bank's careers pages covers the recorded video interview, where they ask you not to use AI tools. Nothing suggests AI help is allowed in live coding either, so practice without it. AI does come up as a topic. In the 2025 onsite the behavioural round asked whether and how the candidate uses AI tools, so have a plain, honest answer ready.

Key Takeaways

  • ✓The August 2025 onsite gave one LeetCode-easy problem an hour, then test cases, then Java change requests on your own code.
  • ✓Write normal and edge test cases before anyone asks, and keep them as JUnit regression tests when the code changes.
  • ✓Prepare two-sentence answers on collections, type erasure, checked versus unchecked exceptions and Java 8 functional interfaces.
Deutsche Bank interview guide

Know what Deutsche Bank asks before you walk in.

28 coding · 5 system design · 29 behavioral questions

Get Premium$49 a year · Instant access
Or start freeNo card.

Get their questions first.

The Online Coding AssessmentHad your Deutsche Bank interview?How we research

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.