Transcript for:
Simply Learn - Coding Interview Questions

hey everyone i hope you're all doing great welcome to simply loans youtube channel and today we'll be discussing about the coding interview questions we will begin this video with some conceptual questions about data structures algorithms and then move on to discussing the coding problems that are most commonly asked to solve in interviews these questions will help you summarize every important programming concept and serve as a perfect preparation resource for coding interviews by the end of this video i can assure you that you will have a proper understanding of data structure concepts and you will be able to code the most common problems asked in interviews so let's get started with an exciting video on coding interview questions before we begin please make sure to subscribe to our youtube channel and hit that bell icon to never miss an update from simply learn so i hope i was clear with the agenda now let's begin with the top 40 coding interview questions that you should know programming interview questions are an integral part of an interview for the developer's position no matter which programming language you master it is expected that you are familiar with the fundamental concepts of the programming coding skills are always the deciding factor in any programming interview we will discuss the top 40 coding interview questions you should absolutely know how to crack in interviews to get your dream job so without further ado let's get started so as discussed the first part would be the conceptual interview questions and that the first question we have to face is what is a data structure so the answer for this question is a data structure is a storage format that defines the way the data is stored organized and manipulated some popular data structures are arrays trees and graphs moving ahead we have our next question that is what is an array so basically all the items that an array stores are of the same data type it organizes data so that a related set of values can be easily sorted or searched now followed by an array the next question we have is about the linked list so what is a linked list it is completely similar to array but there are some basic differences like an array a linked list is a linear data structure in which elements are not necessarily stored in a continuous manner so linked list is basically a sequence of nodes where each node points to the next node forming a chain like structure so followed by the linked list we have the next question which is based on stacks so what exactly is a stack stack is a linear data structure that performs operations in a leaf or order so in a stack elements can only be accessed starting from the top most to the bottom element so followed by stacks we have our next question which is what is a lifo so basically lifo stands for last in first out so it is a way of accessing storing and retrieving data the data that was stored at the last is extracted at the first the next one after lifo is a queue so what exactly is a queue q is a linear data structure that performs operations in a fifo order so basically fifo is first in first out in a queue the least recently added elements are removed first as opposite to the stack so up next we have the fifo so what exactly is fifo fifo stands for first in first out it is a way of accessing storing and retrieving data the data that was stored first is extracted first the next question is about the binary trees so what exactly are binary trees a binary tree is an extension of linkedlist data structure where each node has two children binary tree has two nodes at all the times a left node and a right node so these left and right nodes for the top node are known as children of the top node next we have as recursion so what is recursion recursion refers to a function calling itself based on a terminating condition it uses last and first start functionality and therefore makes use of the stack data structure followed by recursion we have the oops so what is the oops concept oops stands for object-oriented program programming system a paradigm that provides concepts such as objects classes inheritance polymorphism encapsulation etc so what are the concepts introduced in oops so the following concepts are introduced in oops they are object class inheritance polymorphism abstraction and encapsulation now we will discuss each one of them in a bit more detail so we will begin with object a real world entity having a particular state and a behavior is called as an object it can be defined as an instant of a class so next we have the class a logical entity that defines the blueprint from which an object can be created or instantiated is called as a class so basically class is a blueprint which we use to create an object so followed by classes and objects we have the inheritance a concept that refers to an object acquiring all the properties and behaviors of a parent object is called as inheritance so basically inheritance provides code reusability so followed by inheritance the next important concept we have is the polymorphism so polymorphism is a concept that allows the task to be performed in different ways in java we use method overloading and method overriding to achieve polymorphism followed by polymorphism we have the abstraction a concept that hides the internal details of an application and shows only the functionality is called as abstraction in java we use abstract classes and interface to achieve abstraction the last one is the encapsulation encapsulation is a concept that refers to wrapping of code and data together into a single unit so basically every code we have in the java will have data members and data manipulating methods so encapsulation is a basic concept that brings them together and binds them as a single unit so followed by oops concepts the next important question that we will be facing is about the binary search tree so explain binary search tree a binary search tree stores data in such a way that it can be retrieved very efficiently next the left subtree contains nodes both keys are less than that of the node's key value the right sub tree contains nodes those keys are greater than or equal to the node's key value followed by that the next question we have is the doubly linked list so what exactly are doubly linked lists the doubly linked lists are special type of linked list in which traversal across the data elements can be done in both directions this is made possible by having two links in which one of the node will be connected to the next upcoming node and the other link is connected to the previous node so followed by the doubly linked list the next important question we have is the graph so what exactly is a graph a graph is one type of data structure that contains a set of ordered pairs so these ordered pairs are also referred as edges or arcs and arcs are used to connect nodes where data can be stored or retrieved so followed by this we have our next question that is called as the difference between linear and non-linear data structures so the first difference is the linear data structure in which data elements are adjacent to each other and the non-linear data structure is a structure in which each element can connect to two adjacent data elements followed by that the next difference is examples of linear data structure are the arrays linked list stacks and others like queues and examples for non-linear data structures are trees and graphs followed by that the next question is of what is a dq so dq is a double ended queue and this is a structure in which elements can be inserted or removed from either end followed by that we have our next question which says the difference between the stack and an array so stack follows a lifo pattern it means that the data axis follows a sequence in which the last data to be stored is the first element to be extracted next we have the array arrays on the other hand do not follow a particular order and instead can be accessed by referring the indexed element within the array followed by that the next question is which sorting algorithm is the best there are many types of sorting algorithms like quicksort bubble sort balloon sort radix sort merge sort etc and no algorithm can be considered as the best or the fastest because each is designed for a specific type of data structure where it performs the best and our 19th question is how does variable declaration affect memory so the amount of memory can be allocated or reserved depends on the data type being stored in that variable for example if a variable is declared to be integer type then 32 bits of memory storage will be reserved for that variable so the 20th question is what are dynamic data structures so dynamic data structures are the data structures that expand and contract as the program runs it provides a flexible means of manipulating data because it can adjust according to the size of the data so these were the conceptual based questions so far we discussed now next we will move ahead into the programming interview questions so at first we have how do you reverse a string in java so you can see on my screen we have a code segment that is capable of reversing a string so basically you declare a string then take the length of that string loop through the characters of the string and add these characters in the reverse order then print the resultant string next we have how do you determine if a string is a palindrome or not so for that particular question we have a code segment which is capable to reverse the string and check if it is a palindrome or not and accordingly provide the result so a string is a palindrome when it stays the same on the reversing order of characters in that string it is achieved by reversing the original string first and then checking if the reverse string is equal to the original string or not followed by that we have the 23rd question that says find the number of occurrences of a string character in a string so the following code segment is capable to find that particular task and to find the number of occurrences of loop through the string and search for that character in every iteration whenever it is found then the count will be updated followed by that the 24th question is find if the given two strings are anagrams or not two strings are considered as anagrams if they contain similar group of characters in varied sequence so for finding out if two strings are anagrams or not we have the code segment on the right part of my screen right now so basically you declare a boolean value that tells the end of the two strings are anagrams or not then first check the length of the both strings if they are same or not then if they are not same then they are not anagrams if they are same then they are anagrams like they might be a chance of being the two strings as anagrams and followed by the next step is convert both the strings to character arrays then sort them out and finally check the sorted arrays if they are equal or not if they are equal then print their anagrams and if they are not equal then you should print not anagrams the next 25th question is how do you calculate the number of wobbles and consonants in a string so you can see on my screen i have a code segment which will be capable of counting bubbles and consonants in a string so look through the string so that's the first step followed by that increase the vocal variable by 1 whenever the character can be found as a vowel using the if condition otherwise increment the consonant variable finally print the values of both the vowels and consonants count the next important question we will be facing in the coding interview is how do you get matching elements in an integer array so for that we have a code segment on my screen right away now the steps for that are declare an array nest a couple of loops and compare the numbers with the other numbers in the array and finally print the matching elements whenever found so next we have this 27th question that says code bubbles out algorithm you don't have to code the entire bubble sort algorithm what you can do is just write the code segment which has a logic for it so that is currently on my screen right now so what you basically do is declare an array so next what you do is nest a couple of loops and compare the numbers in that array and then the array will be sorted in the ascending order by replacing the elements if found in any other order 28th question is code the insertion sort algorithm so this is completely similar approach what we followed for the bubble sort you just have to write the code segment of logic so the steps will be first the element in the array is assumed to be sorted take the second element and then store it separately in key now the first two elements are like sorted take the third element and then compare it with the elements in the left of it the process goes on until the array is sorted so next we have the 29th question how do you reverse an array so you can see on my screen we have a code segment that says how to reverse an array loop till the half length of the array next we have to replace the numbers corresponding to the indexes from the starting to the end followed by that we have the 30th question where we have to find a way to swap two numbers without the third variable so this type of interview question will be asked most number of times to the beginners most frequently now the solution for that has been written on my screen right away you can check out that and the steps to be followed are declare two variables and initialize them with the values make b the sum of both the numbers then subtract the sum that is the b from a so a is now swapped lastly subtract a from the sum b so b is now also swapped next we have the 31st question which says print a fibonacci series using recursion so for that we have a code segment which can print a fibonacci series on my screen right now so the code on my screen can be used to print the fibonacci series so basically what are fibonacci numbers so the fibonacci numbers are the numbers in the following integer sequence 0 1 1 2 3 5 8 13 21 and so on they can be calculated using the mathematical formula used in the fibonacci recursive function the next question you'll be facing is how do you find the factorial of an integer so we have the code segment on my screen which can perform the factorial of an integer operation so the factorial is a function that multiplies a number by every number below it for example factorial of 5 is 5 into 4 into 3 into 2 into 1 which is equal to 120. so recursive function multiplies the number until it reaches 1. the next one is how do you reverse a linked list so for that we have the code segment on my screen right away you can please check it out and try it so if you can find out if it can reverse a linked list or not so the steps to be done for that are declare a linked list first then add elements to that linked list apply the descending iterator method to the linked list and then they should reverse the order of the elements in the linked list the 34th question is how do you implement the binary search so for that we have the code segment right on my screen you can check that out and the steps to be followed are mentioned in the code segment so the binary search divides the array into half in every iteration step until it finds the element it works on sorted arrays since it compares the values of adjacent elements and then calculates the middle number if the value of low becomes greater than high at any point it means the element is not present in the list so this is how the binary search basically works followed by that we have the 35th question which says find the second largest number in the array so you can see we have a code segment on my screen to find it out so the steps to be followed are loop through the array if the value of i is greater than the highest store the value of i in the highest and store the value of highest in the second highest variable so now let's move ahead to the 36th question how do you remove all occurrences of a given character from the input string so we have a simple small code segment on my screen right away so that code segment can be used to remove all the occurrences of a given character from an input string so what you can do is use the built in string method that is replace to replace a character with any other character including symbols and white spaces so followed by that we have our 37th question so that is showcase inheritance with the help of a program so we have a small course limit on my screen to showcase the one of the major object oriented programming method that is inheritance so the class cat inherits the property color from class animal by extending the parent class animal this way a class cat can have more parent classes if it wishes to inherit their properties as well so next question that is the 38th question is explain overloading and overriding with the help of a program so this is a major question which is asked many number of times most frequently for the beginners and sometimes even the experienced candidates cannot escape this question so first we'll discuss overloading when a class has two or more methods with the same name they are called as overloaded methods so you can see a code segment on the right side part of my screen right away so this is an example for overloading next we will discuss the overriding so next we will discuss the overriding so when a superclass method is also implemented in the child class then it's a clear case of overriding so on the right side part of my screen you can see a code segment where a child class is extending the base class method which is print name now followed by that we have the 39th question that is check if the given number is prime or not so you can see a code segment on my screen which determines if the given number is a prime number or not so the steps to be followed to find if a given number is prime or not r use if statements to check for each condition separately if the number is 0 or 1 it cannot be prime if the number is 2 it is prime if the number is and finally the third condition you need to take care of is if the number is indivisible by other numbers then it is prime so basically prime numbers are divisible by 1 or itself if any other number is capable to divide the number then it is not a prime number now the last question in the list is how do you sum all the elements in an array so for that we have a code segment right on my screen please check it and try to run it and that's the best way to learn so the steps to be followed are use the loop to iterate through the array and keep adding the elements in that array and finally you will get the sum of the elements in the array and you can just print this sum at the last so with that as you prepare for your upcoming job interview we hope these coding questions have provided more insight into what types of questions you are likely to be asked and with that we have come to an end of this video on coding interview questions i hope it was informative and interesting if you have any questions about any topics covered in this video please feel free to ask in the comment section below our team of experts will be happy to solve all your queries thank you for watching stay safe and keep learning hi there if you like this video subscribe to the simply learn youtube channel and click here to watch similar videos turn it up and get certified click here