Arrays and Strings Interview Questions for C Programming with DSA
25 Arrays and Strings questions with answers for c programming with dsa roles — 11 easy, 11 medium, 3 hard.
About Arrays and Strings
Arrays and strings dominate coding rounds. Learn one and two dimensional arrays, null terminated strings, safe string functions and buffer overflows, then key problem solving patterns such as two pointers, sliding window, prefix sums, Kadane's algorithm and in-place array tricks, all written and practised in clean C code.
What is the difference between char s[] = "hello" and char *s = "hello"?
Show answer
Why is gets() dangerous and what should you use instead?
Show answer
What is the two-pointer technique and when is it used?
Show answer
An interview asks you to find the missing number from 1 to n in an array of n-1 numbers. What approaches work?
Show answer
Reverse a string in place in C.
Show answer
Merge two sorted arrays into a third sorted array.
Show answer
Implement your own strcmp function.
Show answer
Write a C function to count words in a sentence.
Show answer
How did you improve your problem solving skills?
Show answer
What does it mean that arrays decay to pointers when passed to functions?
Show answer
What is the difference between strcpy, strncpy and snprintf for copying strings?
Show answer
How is a 2D array stored in memory in C?
Show answer
What is the sliding window technique?
Show answer
What is a prefix sum array and why is it useful?
Show answer
Explain Kadane's algorithm.
Show answer
A strlen call crashes on a buffer received from a network packet. What is wrong?
Show answer
You need to find whether any two numbers in an unsorted array sum to a target. Compare approaches.
Show answer
Write Kadane's algorithm in C.
Show answer
Rotate an array to the right by k positions in O(n) time and O(1) space.
Show answer
Find the length of the longest substring without repeating characters in C.
Show answer
Describe how you approach a coding problem you have never seen before.
Show answer
What is a buffer overflow and how can it be prevented in C?
Show answer
A matrix multiplication in C is very slow for 2000 by 2000 matrices. How would you speed it up?
Show answer
Find the majority element that appears more than n/2 times in O(n) time and O(1) space.
Show answer
Frequently asked questions
How important is Arrays and Strings in C Programming with DSA interviews?
Arrays and strings dominate coding rounds. Learn one and two dimensional arrays, null terminated strings, safe string functions and buffer overflows, then key problem solving patterns such as two pointers, sliding window, prefix sums, Kadane's algorithm and in-place array tricks, all written and practised in clean C code.
How should I use the Arrays and Strings sheet?
Go top to bottom — easy to hard. Answer before opening each answer, tick what you solved and save misses to Last-Minute Revision.