International Business Machines Corporation (IBM) is a leading American multinational technology company with a presence in over 175 countries. Founded in 1911, IBM is known for its innovations in computing, including the automated teller machine (ATM) and relational database. As the largest industrial research organization, it has held the record for the most annual U.S. patents for 29 years.
IBM's focus on quantum computing, artificial intelligence, and data infrastructure underscores its commitment to shaping the tech landscape. The IBM software developer coding round questions are crucial for evaluating candidates, making it a key step in recruitment.
Concepts to Look for IBM Software Developer Coding Questions
Candidates can expect a range of topics during IBM coding assessments, including:
- OOP Concepts
- Data Types
- Recursion
- Functions
- Complexity Theory
- Arrays
- Linked Lists
- Graphs
- Trees
- Queues
- Stacks
- Hash Tables
- Heaps
- Searching and Sorting
Top IBM Coding Questions and Answers Asked for Software Developer
Candidates can expect these IBM coding questions with answers for software developers:
Problem Statement 1: Given a string s, find the number of unique characters in the string.
Input Format
- The first line contains a single integer T, the number of test cases.
- The next T lines each contain a string s (1 ≤ |s| ≤ 1000).
Output Format
- For each test case, output a single integer, the count of unique characters in the string.
Example
Input
3
hello
world
python
Output
4
5
6
C++
#include <iostream>
#include <unordered_set>
#include <string>
int main() {
int T;
std::cin >> T;
while (T--) {
std::string s;
std::cin >> s;
std::unordered_set<char> unique_chars(s.begin(), s.end());
std::cout << unique_chars.size() << std::endl;
}
return 0;
}
Problem Statement 2: Given an array of integers, find the maximum sum of a contiguous subarray.
Input Format
The first line contains a single integer T, the number of test cases.
Each test case consists of
- A line containing an integer n, the size of the array.
- A line containing n space-separated integers representing the array elements.
Output Format
- For each test case, output a single integer representing the maximum sum of the contiguous subarray.
Example
Input
2
5
-2 1 -3 4 -1 2 1 -5 4
4
1 -2 3 -4
Output
6
3
C++
#include <iostream>
#include <vector>
#include <algorithm>
int maxSubArray(const std::vector<int>& nums) {
int max_sum = nums[0];
int current_sum = nums[0];
for (size_t i = 1; i < nums.size(); ++i) {
current_sum = std::max(nums[i], current_sum + nums[i]);
max_sum = std::max(max_sum, current_sum);
}
return max_sum;
}
int main() {
int T;
std::cin >> T;
while (T--) {
int n;
std::cin >> n;
std::vector<int> nums(n);
for (int i = 0; i < n; ++i) {
std::cin >> nums[i];
}
std::cout << maxSubArray(nums) << std::endl;
}
return 0;
}
Problem Statement 3: Write a function to check if a given string is a palindrome. A palindrome is a string that reads the same backward as forward.
Input Format
- The first line contains a single integer T, the number of test cases.
- The next T lines each contain a string s (1 ≤ |s| ≤ 1000).
Output Format
- For each test case, output "YES" if the string is a palindrome, otherwise output "NO".
Example
Input
3
madam
hello
racecar
Output
YES
NO
YES
C++
#include <iostream>
#include <string>
bool isPalindrome(const std::string &s) {
int left = 0, right = s.size() - 1;
while (left < right) {
if (s[left] != s[right]) {
return false;
}
left++;
right--;
}
return true;
}
int main() {
int T;
std::cin >> T;
while (T--) {
std::string s;
std::cin >> s;
std::cout << (isPalindrome(s) ? "YES" : "NO") << std::endl;
}
return 0;
}
Problem Statement 4: Given two strings, determine if they are anagrams of each other. Two strings are anagrams if they contain the same characters with the same frequencies.
Input Format
- The first line contains a single integer T, the number of test cases.
- The next T lines each contain two strings s1 and s2.
Output Format
- For each test case, output "YES" if the strings are anagrams, otherwise output "NO".
Example
Input
3
listen silent
hello world
evil vile
Output
YES
NO
YES
C++
#include <iostream>
#include <string>
#include <unordered_map>
bool areAnagrams(const std::string &s1, const std::string &s2) {
if (s1.size() != s2.size()) return false;
std::unordered_map<char, int> char_count;
for (char c : s1) {
char_count[c]++;
}
for (char c : s2) {
char_count[c]--;
if (char_count[c] < 0) return false;
}
return true;
}
int main() {
int T;
std::cin >> T;
while (T--) {
std::string s1, s2;
std::cin >> s1 >> s2;
std::cout << (areAnagrams(s1, s2) ? "YES" : "NO") << std::endl;
}
return 0;
}
₹ 49,000
Karthik was able to transform his career from a boring job to an
exciting job in software!
Talk to a career expert
Problem Statement 5: Given a string, count the number of vowels in it.
Input Format
- A single string s (1 ≤ |s| ≤ 1000).
Output Format
- Output a single integer, the count of vowels in the string.
Example
Input
Hello World
Output
3
C++
#include <iostream>
#include <string>
int countVowels(const std::string& s) {
int count = 0;
for (char c : s) {
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ||
c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') {
count++;
}
}
return count;
}
int main() {
std::string s;
std::getline(std::cin, s); // Read the entire line of input
std::cout << countVowels(s) << std::endl;
return 0;
}
Problem Statement 6: Determine if a given integer is a prime number.
Input Format
- A single integer n (1 ≤ n ≤ 10^6).
Output Format
- Output "YES" if n is a prime number, otherwise "NO".
Example
Input
29
Output
YES
C++
#include <iostream>
bool isPrime(int n) {
if (n <= 1) return false;
for (int i = 2; i * i <= n; ++i) {
if (n % i == 0) return false;
}
return true;
}
int main() {
int n;
std::cin >> n;
std::cout << (isPrime(n) ? "YES" : "NO") << std::endl;
return 0;
}
Problem Statement 7: Merge two sorted arrays into one sorted array.
Input Format
- The first line contains two integers n and m, the sizes of the two arrays.
- The second line contains n space-separated integers (first sorted array).
- The third line contains m space-separated integers (second sorted array).
Output Format
- Output the merged sorted array.
Example
Input
3 4
1 3 5
2 4 6 8
Output
1 2 3 4 5 6 8
C++
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
int n, m;
std::cin >> n >> m;
std::vector<int> arr1(n), arr2(m);
for (int i = 0; i < n; ++i) std::cin >> arr1[i];
for (int i = 0; i < m; ++i) std::cin >> arr2[i];
std::vector<int> merged(n + m);
std::merge(arr1.begin(), arr1.end(), arr2.begin(), arr2.end(), merged.begin());
for (int num : merged) {
std::cout << num << " ";
}
return 0;
}
Problem Statement 8: Calculate the nth Fibonacci number.
Input Format
- A single integer n (0 ≤ n ≤ 30).
Output Format
- Output the nth Fibonacci number.
Example
Input
10
Output
55
C++
#include <iostream>
int fibonacci(int n) {
if (n == 0) return 0;
if (n == 1) return 1;
int a = 0, b = 1, c;
for (int i = 2; i <= n; ++i) {
c = a + b;
a = b;
b = c;
}
return b;
}
int main() {
int n;
std::cin >> n;
std::cout << fibonacci(n) << std::endl;
return 0;
}
Tips for Cracking IBM Software Developer Coding Questions
To excel in the IBM coding interviews, consider the following tips:
- Use platforms like HackerRank and CodeSignal to practice coding problems.
- Understanding the basics of data structures and algorithms is crucial.
- Participate in mock interviews to build confidence and improve your communication skills.
- Ensure you fully understand the problem before attempting to solve it.
- Aim for the most efficient solution and be prepared to discuss its time and space complexity.
Conclusion
In conclusion, solving IBM coding questions for software developers is crucial for candidates who want to get a job at IBM. By focusing on common topics, practicing regularly, and using effective problem-solving strategies, you can significantly improve your chances of success in IBM coding assessments.
₹ 49,000
Karthik was able to transform his career from a boring job to an
exciting job in software!
Talk to a career expert
Frequently Asked Questions
1. What types of coding questions are asked in IBM interviews?
Commonly, candidates face questions related to data structures, algorithms, and general problem-solving.
2. Where can I find IBM coding questions for practice?
Platforms like Nxtwave LastMinutePro, Leetcode, and HackerRank often host IBM coding questions, making them an excellent resource for preparation.