Coding questions for interview :-
Greetings, fellow enthusiasts of the software development realm! Embarking on a career journey, particularly at the outset, necessitates a touch of luck in securing that coveted first interview. This sentiment holds true across all career stages, but the challenges are notably pronounced for beginners seeking their initial job opportunities.
The computer science graduate and software developer community faces a deluge of applications, spanning startups like Uber and Netflix to tech giants such as Amazon, Microsoft, and Google, alongside service-based firms like Wipro. Yet, many applicants grapple with the uncertainty of what programming interview questions might await them in these pursuits.
In this article, I aim to demystify the interview process by sharing frequently asked questions across various experience levels, from fresh graduates to those with a year or two of industry exposure. Coding interviews typically delve into data structures, algorithms, and logical problem-solving, such as the classic inquiry: how to swap two integers without a temporary variable?
It’s crucial to practice coding on paper—a departure from the comfort of IDEs and Stack Overflow. This not only challenges you but also replicates the realism of a whiteboard interview.
Understanding the core concepts of algorithms and mastering the requirements of different data structures is paramount for success. Now, let’s explore 20 commonly asked questions, spanning general inquiries that gauge your knowledge and bonus questions that often make an appearance in interviews.
Feel free to add any additional questions you deem necessary in the comments below. In subsequent sections, we’ll delve into specific topics like Array-List, strings, and more. Whether you’re a fresh graduate or a seasoned professional, let’s unravel the intricacies of software development interviews together.
Table of Contents
There are usually random questions asked in interview .
- swiping Program
like a=50;
b=10;
output:- b=50, and a =10
Answer: Solution - short array without the use of a short function
input :-var a= [1,2,5,3,4,6,7,8];
output :-var a=[1,2,3,4,5,6,7,8];
Answer: Solution - get the second largest number of the array list.
input :- a= [1,2,5,3,4,6,7,8];
output :- 7;
Answer: Solution - write a program that generates 50 prime number
example of prime number is :- 2,3,5,7,9,11,13,17,19,23,29….
Answer: Solution - reverse string without loop or predefined function(like reverse)
Like: var name =”shirsh”
after reverse: var name =”hsrihs”
Answer: Solution - Create and Add a two matrix 2×2 or 3×3.
Answer: Solution - Count repeated items in a String.
Like: var name =” Shirsh”
so, “s”=2 times, “h”=2 times, “i”=1 time, “r”= 1 time
Answer: Solution - how to check the name of the number in English?
For: if I assign any variable:- var num =121
so print this number in English letter, means on console print result is -:
“one hundred twenty-one”
Answer: Solution - How to get the matching characters and non-matching characters in a string.
Example:-
Input: str1 = “abcdef”, str2 = “defghia”
Output: 4
Matching characters are: a, d, e, f
Answer: Solution - How to calculate the number of vowels and consonants in a string?
Answer: Solution - Determine the factors of a number.
Answer: Solution - Compute the first Ten Fibonacci numbers.
Answer: Solution - How to get the third node of a linked list?
Answer: Solution - How to search for a specific value in a linked list?
Answer: Solution - How to remove special characters in a string that is in lowercase?
Answer: Solution - How to find multiple missing numbers in a given integer array with duplicates?
Answer: Solution - How to find all permutations of String?
Answer: Solution - writes a program for Sudoku.
Answer: Solution - How to check if a given number is a Palindrome?
Answer: Solution - How to calculate the average of all numbers in a given array?
Answer: Solution - Write a Program to check if a given year is a leap year.
Answer: Solution - Write Program to check whether the number is Palindrome or not.
Answer: Solution - Write a Program to check whether the number is a Narcissistic number or not.
Answer: Solution - Write a Program to print all numbers of a list in a random manner and all numbers should be only one, without using any pre-defined function.
input :- a= [1,2,5,3,4,6,7,8,8,8,8,9,9,9];
output :- a = [2,4,9,7,1,3,6,5,8];
Answer: if you have Please comment below. - Find the Fastest way to find an index of elements in a list. (ex:-binary search)
input :- var list =[1,2,3,4,5,6,7,8,9,10,11,12,13,14];
var numFind =2;
output:- 1 Index
Answer:- Solution - Find the sum of all natural numbers without using any regression or any loop.
Answer:- Solution - Find the nearest smaller numbers on the left side in an array.
Answer:- Solution - Find the minimum number of coins that make a given value.
Input: V = 70
Output: 2
We need a 50 Rs note and a 20 Rs note.
Answer:- Solution - Find the index of two array elements whose sum is equal to the given value
Coding interview questions for arrays
- How do remove duplicates from a given array?
(solution) - How do you search for a target value in a rotated array?
(solution) - How do you find the missing number in a given integer array of 1 to 100? (solution)
- How do you find the duplicate number on a given integer array?
(solution) - How do you find the largest and smallest number in an unsorted integer array?
(solution) - How do you find all pairs of an integer array whose sum is equal to a given number?
(solution) - How do you remove duplicates from an array in place?
(solution) - How to rotate an array left and right by a given number K?
(solution) - How do you find duplicates from an unsorted array?
(solution) - Given an array of integers sorted in ascending order, find the starting and ending position of a given value.
(solution) - Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
(solution) - How is an integer array sorted in place using the quicksort algorithm? (solution)
- Given an integer array, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
(solution) - How do you reverse an array in place in Java?
(solution) - How are duplicates removed from an array without using any library? (solution)
- How to convert a byte array to a String?
(solution) - What is the difference between an array and a linked list?
(solution) - How do you perform a binary search in a given array?
(solution) - How to find a median of two sorts of arrays?
(solution) - How do you find duplicate numbers in an array if it contains multiple duplicates?
(solution)
Coding interview questions on linked lists
- How do you reverse a linked list?
(solution) - How to add an element in the middle of the linked list?
(solution) - How to find the node at which the intersection of two singly linked lists begins.
(solution) - How to check if a given linked list is a palindrome or not?
(solution) - How do you find the middle element of a singly linked list in one pass? (solution)
- How do you check if a given linked list contains a cycle? How do you find the starting node of the cycle?
(solution) - How do you find the third node from the end in a singly linked list? (solution)
- How do you find the sum of two linked lists using Stack?
(solution) - How to Delete all occurrences of a given key in a linked list?
(solution) - How do you reverse a linked list?
(solution) - How do you sort a linked list in Java?
(solution) - What is the difference between the array and linked list?
(Solution) - How to remove Nth Node from the end of a linked list?
(solution) - How to merge two sorted linked lists?
(solution) - How to convert a sorted list to a binary search tree?
(solution) - Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
(solution) - How to remove duplicates from a sorted linked list?
(solution) - How do you reverse a singly linked list without recursion?
(solution) - How are duplicate nodes removed in an unsorted linked list?
(solution) - How do you find the length of a singly linked list?
(solution)
Coding interview questions for strings
- How do you reverse a given string in place?
(solution) - How do you print duplicate characters from a string?
(solution) - How do you check if two strings are anagrams of each other?
(solution) - How do you find all the permutations of a string?
(solution) - How can a given string be reversed using recursion?
(solution) - How do you check if a string contains only digits?
(solution) - How do you find duplicate characters in a given string?
(solution) - How do you count the number of vowels and consonants in a given string? (solution)
- How do you count the occurrence of a given character in a string? (solution)
- How do you print the first non-repeated character from a string?
(solution) - How do you convert a given String into int like the atoi()?
(solution) - How do you reverse words in a given sentence without using any library method?
(solution) - How do you check if two strings are a rotation of each other?
(solution) - How do you check if a given string is a palindrome?
(solution) - How to find the length of the longest substring without repeating characters?
(solution) - Given a string, find the maximum length contiguous substring of it that is also a palindrome. For example, the longest palindromic substring of “bananas” is “anana”, and the longest palindromic substring of “abdcbcdbdcbbc” is “bdcbcdb”.
(solution) - How to convert a byte array to a String?
(solution) - how do remove the duplicate character from String?
(solution) - How to find the maximum occurring character in a given String? (solution)
- How do you remove a given character from a String?
(solution)
Coding interview questions for Binary Tree
- How do you implement a postorder traversal algorithm?
(solution) - How do you traverse a binary tree in postorder traversal without recursion?
(solution) - How are all leaves of a binary search tree printed?
(solution) - How do you count the number of leaf nodes in a given binary tree? (solution)
- You have given a BST, where two nodes are swapped? How do you recover the original BST?
(solution) - How is a binary search tree implemented?
(solution) - How do you perform preorder traversal in a given binary tree?
(solution) - How do you traverse a given binary tree in preorder without recursion? (solution)
- How do you perform an inorder traversal in a given binary tree?
(solution) - How do you print all nodes of a given binary tree using inorder traversal without recursion?
(solution) - How do you convert a binary tree to a binary search tree?
(solution) - Find the largest BST subtree of a given binary tree.
(solution) - Write a program to connect nodes at the same level as a binary tree. (solution)
- What is a Trie data structure?
(solution) - How do you perform a binary search in a given array?
(solution) - How to Convert a given Binary Tree to a Doubly Linked List?
(solution) - Write a Program to Find the Maximum Depth or Height of a Tree.
(solution) - What is the difference between binary and binary search trees?
(solution) - What is a Self-Balancing Binary Search Trees?
(solution) - What is the AVL Tree?
(solution)
Coding interview questions for Graph
- Print Adjacency List for a Directed Graph.
(solution) - what is the Difference between BFS and DFS?
(solution) - Write a to Count all possible paths between two vertices.
(solution) - Find the minimum number of throws required to win a given Snakes and Ladders board game.
(solution) - Find a Word in a 2D Grid of characters.
(solution) - Find the Distance of the nearest cell having 1 in a binary matrix.
(solution) - Find the number of islands.
(solution) - Find a Mother Vertex in a Graph.
(solution) - Implement Dijkstra’s Algorithm
(solution) - Find the most similar path in a graph.
(solution) - Given a sorted dictionary of an alien language, find the order of characters.
(solution) - Check whether a given graph is Bipartite or not.
(solution) - Keys and Rooms question.
(solution) - question on Articulation Points (or Cut Vertices) in a Graph.
(solution) - Tarjan’s Algorithm to find Strongly Connected Components.
(solution) - How to find all bridges in a graph?
(solution) - what is Maximum Bipartite Matching?
(solution) - Find all possible worlds in a board of characters(Boggle)
(solution) - Given a matrix of ‘O’ and ‘X’, replace ‘O’ with ‘X’ if surrounded by ‘X’.
(solution) - find the Shortest path to reach one prime to another by changing a single digit at a time.
(solution)
That concludes the compilation of questions for your practice. Remember, understanding the core logic is paramount. Comprehend the essence of each question, for mastering its core concept enables you to tackle similar queries with confidence.
These questions are sourced from various reputable websites, and while every effort has been made to ensure accuracy, discrepancies may exist. Your feedback is invaluable. If you spot any inaccuracies or feel a significant question has been omitted, kindly share your insights in the comments below.
Happy coding, and may your preparation pave the way for success in your software development interviews!
Related Links:-
You can practice more coding questions at:-
How to get free Mooc Certificate visit here
- SWE- Frontend at Alphablocks (Remote)
- Frontend Developer at Lumel
- Software Development Engineer at Amadeus
- Software Engineer Intern at ZadaraSoftware Engineer Intern at
- Parallel Wireless Fresher Software Engineer Trainee Recruitment
Best websites for coding practice
Online Compilers
https://www.programiz.com/c-programming/online-compiler/
https://www.onlinegdb.com/online_c_compiler
https://onecompiler.com/c