C Developer
C Developer Interview Questions and Answers for Freshers
Q1. String Transformation Problem
Given a string (STR
) of length N
, you are tasked to create a new string through the following method:
Select the smallest character from the first K
characters of STR
, remove it fr...read more
Given a string and an integer, create a new string by selecting the smallest character from the first K characters of the input string and repeating the process until the input string is empty.
Iterate through the input string, selecting the smallest character from the first K characters each time.
Remove the selected character from the input string and append it to the new string.
Continue this process until the input string is empty.
Return the final new string formed.
Q2. Merge K Sorted Arrays Problem Statement
Given 'K' different arrays that are individually sorted in ascending order, merge all these arrays into a single array that is also sorted in ascending order.
Input
The f...read more
Merge K sorted arrays into a single sorted array.
Create a min heap to store the first element of each array along with the array index.
Pop the top element from the heap, add it to the result array, and push the next element from the same array back to the heap.
Continue this process until all elements are processed.
Time complexity can be optimized using a priority queue or merge sort technique.
Q3. Sort 0 1 2 Problem Statement
Given an integer array arr
of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.
Input:
The first line contains an integer 'T' representing the number of...read more
Sort an array of 0s, 1s, and 2s in linear time complexity.
Use three pointers to keep track of 0s, 1s, and 2s while iterating through the array.
Swap elements based on the values encountered to sort the array in-place.
Ensure to handle edge cases like all 0s, all 1s, and all 2s in the array.
Q4. Find Maximum Number by At-most K Swaps
Given an array of non-negative integers representing the digits of a number and an integer 'K', calculate the maximum possible number by swapping its digits up to 'K' time...read more
Given an array of digits and an integer K, find the maximum number by swapping digits up to K times.
Sort the digits in non-increasing order to maximize the number.
Swap the digits to achieve the maximum number within the given number of swaps.
Handle cases where there are repeating digits and leading zeros.
Q5. BST Node Deletion Problem
Given a binary search tree (BST) and a key value K
, your task is to delete the node with value K
. It is guaranteed that a node with value K
exists in the BST.
Explanation:
A binary sea...read more
Delete a node with a given value from a binary search tree (BST).
Traverse the BST to find the node with the value K to be deleted.
Handle different cases like node with no children, one child, or two children.
Update the pointers of the parent node and child nodes accordingly.
Recursively delete the node and adjust the tree structure.
Return the root of the modified BST after deletion.
Q6. Move Zeroes to End Problem Statement
Given an unsorted array of integers, modify the array such that all the zeroes are moved to the end, while maintaining the order of non-zero elements as they appear original...read more
Move all zeroes to the end of an unsorted array while maintaining the order of non-zero elements.
Iterate through the array and keep track of the index to place non-zero elements.
Once all non-zero elements are placed, fill the rest of the array with zeroes.
Ensure to maintain the relative order of non-zero elements.
Example: Input: [0, 1, -2, 3, 4, 0, 5, -27, 9, 0], Output: [1, -2, 3, 4, 5, -27, 9, 0, 0, 0]
Share interview questions and help millions of jobseekers 🌟
Q7. Preorder Traversal of a BST Problem Statement
Given an array PREORDER
representing the preorder traversal of a Binary Search Tree (BST) with N
nodes, construct the original BST.
Each element in the given array ...read more
Given a preorder traversal of a BST, construct the BST and return its inorder traversal.
Create a binary search tree from the preorder traversal array
Return the inorder traversal of the constructed BST
Ensure each element in the array is distinct
Q8. How to delete the middle element of a linked list?
To delete the middle element of a linked list, find the middle element using slow and fast pointers, then remove it by adjusting the pointers.
Use slow and fast pointers to find the middle element
Adjust pointers to skip the middle element and connect the surrounding nodes
Free the memory of the deleted node
C Developer Jobs
Q9. Difference between multi-programming and multi-tasking.
Multi-programming involves running multiple programs on a single processor, while multi-tasking involves running multiple tasks within a single program.
Multi-programming allows multiple programs to be loaded into memory and executed concurrently, switching between them to utilize processor time efficiently.
Multi-tasking allows a single program to perform multiple tasks simultaneously, such as running multiple threads or processes within the program.
Examples of multi-programmi...read more
Interview Questions of Similar Designations
Top Interview Questions for C Developer Related Skills
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month