Baidu Coding Interview Questions
25 Baidu coding interview problems with full optimal solutions — 11 easy, 11 medium, 3 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Baidu interviewer values, and a FAQ section.
Showing 11 problems of 25
- #1easyfoundational
1. Two Sum
Find two indices in an array whose values sum to a target.
- #2easyfoundational
2. Valid Parentheses
Determine if a string of brackets is properly opened and closed.
- #3easyfoundational
3. Merge Two Sorted Lists
Combine two sorted linked lists into one sorted list.
- #4easyfoundational
4. Remove Duplicates from Sorted Array
Remove duplicates from a sorted array in-place and return the new length.
- #5easyfoundational
5. Same Tree
Decide whether two binary trees are structurally identical and hold the same values at every node.
- #6easyfoundational
6. Maximum Depth of Binary Tree
Return the length of the longest root-to-leaf path in a binary tree.
- #7easyfoundational
7. Best Time to Buy and Sell Stock
Find the maximum profit from a single buy-then-sell over a daily price series.
- #8easyfoundational
8. Single Number
Find the one element in an array where every other element appears exactly twice.
- #9easyfoundational
9. Linked List Cycle
Detect whether a singly linked list contains a cycle, using only O(1) extra memory.
- #10easyfoundational
10. Majority Element
Find the element that appears more than n/2 times in an array of length n.
- #11easyfoundational
11. Reverse Linked List
Reverse a singly linked list in-place and return the new head.