Print All Duplicates in an Array
Problem
Given an array of integers, print all elements that occur more than once.
Example:
Input: [10, 20, 20, 30, 30, 30, 40, 50, 50]
Output: 20 30 30 50
Coding
1 sections, 8 questions
Given an array of integers, print all elements that occur more than once.
Example:
Input: [10, 20, 20, 30, 30, 30, 40, 50, 50]
Output: 20 30 30 50
Given the head of a linked list, determine whether it contains a cycle.
Example:
Input: A linked list where the last node points back to a previous node
Output: true (cycle detected) / false (no cycle)
Given an array and a target sum, determine whether any pair of elements sums to the target.
Example:
Input: arr = [1, 4, 45, 6, 10, -8], target = 16
Output: true
Explanation: 6 + 10 = 16
Given the head of a linked list and a value range [low, high], return the list with all nodes whose values fall within that range removed. (Asked in the IBM CIO Campus online assessment on HackerRank.)
Example:
Input: list = 1 -> 5 -> 2 -> 8 -> 3 -> 10, low = 2, high = 5
Output: 1 -> 8 -> 10
Write a program to reverse the digits of a given integer. (Asked in an IBM Software Engineer technical interview round.)
Example:
Input: 12345
Output: 54321
Write a program to reverse an array of integers in place. (Asked in the same IBM Software Engineer technical interview round.)
Example:
Input: [10, 20, 30, 40, 50]
Output: [50, 40, 30, 20, 10]
Explain and implement the bubble sort algorithm. (Asked in the same IBM Software Engineer technical interview round.)
Example:
Input: [64, 34, 25, 12, 22, 11, 90]
Output: [11, 12, 22, 25, 34, 64, 90]
Print the letter 'N' using asterisks/characters in any programming language. (Asked in the IBM CIO Campus in-person interview as a quick coding task.)
Example:
Output (5x5):
* *
** *
* * *
* **
* *