Question: Given two strings, determine if they share a common substring. Input: “a” and “art” Output: YES Problem Statement Let me try to simplify this problem statement first. You are given two strings, and you need to find out if they share a common substring or not. If you can find a common substring, output “YES”, else output “NO”. Note that you don’t have to find out what is the common substring. Another important aspect of this problem is that the substring can be as small as 1 character. A…
nikoo28
nikoo28
a techsavvy guy and a design buff... I was born with the love for exploring and want to do my best to give back to the community. I also love taking photos with my phone and Canon Kiss X5 in order to capture moments in my life. It's my pleasure to have you here.


Question: You will be given two arrays of integers and asked to determine all integers between two sets that satisfy the following two conditions:– The elements of the first array are all factors of the integer being considered– The integer being considered is a factor of all elements of the second array Input:a = { 2, 6 }b = { 24, 36 } Output:2 I really want to simplify this really confusing problem statement first. The hardest part about this problem is to understand what is it actually saying. To…

Question: Given an array of integers, find the number of pairs of array elements that have a difference equal to the target value. Example: Input:arr[ ] = {1, 2, 3, 4}k = 1 Output: 3 Problem Statement Let us try to simplify the problem statement first and understand the sample test case. You are given an array of unique integers which is in any random order. Along with the array, you are also given a target value k. If you pick up any 2 integers from the array, they would…

Question: You are required to find missing numbers that are left out while an artist transports numbers from one array to other. The output array should be sorted. Input:arr [ ] = {7, 2, 5, 3, 5, 3}brr [ ] = {7, 2, 5, 4, 6, 3, 5, 3} Output:Missing numbers: {4, 6} Problem Statement: Let me try to simplify the problem a little first. The problem description is quite verbose and we narrow down it to quite an extent. To summarize, the artist has an original array brr, and…

Question: Given 3 arrays, where each element represent the height of a cylinder. Find the maximum possible height of equal stacks by removing one or more cylinders from the original stack. Example: Input: n1[] = {3, 2, 1, 1, 1}n2[] = {4, 3, 2}n3[] = {1, 1, 4, 1} Output: 5 Problem Statement Let us try to simplify the problem statement first. The problem states that you are provided with 3 sets of arrays. Each element in the array represents the height of a cylinder. Now, all these cylinders are…

Question: You are given an array of integers. After a left rotation of k times, find the resultant array. Example 1:Input: arr [ ] = {1, 2, 3, 4, 5}, size = 5, k = 2Output: {3, 4, 5, 1, 2} Example 2:Input: arr [ ] = {4, 8, 15, 16, 23, 42}, size = 6, k = 12Output: {4, 8, 15, 16, 23, 42} Terminology: To understand rotation of an array, you can assume that the array is kind of on an infinite conveyor belt, that keeps on looping.…

There can be several aspects when you think about analysis of algorithms. You may be writing a large scale application where you have to decide between two choices. You may be trying to submit a solution to some online competition and you want a higher score, or probably you may just want to write fewer lines of code. Analysis during an Interview Let’s say you are appearing for an interview. The person who is interviewing you gives you a problem to solve. He or she is not just interested in…

As soon as you hear the word ‘Big O’, does your mind go “Oh my god! Oh no! This again?” The next thing following it would be time complexity and what not. Suddenly, your brain starts getting this confusing signals and you lose track of what is happening. If you have felt this at some point of time while learning programming, then I want to tell you that you are not alone. In fact, you are proceeding in the right direction. But all these notations can start to get overwhelming…

The first thing that comes to our mind on hearing the word recursion is doing a thing over and over again. But how can you expect to achieve a solution to a problem by repeating the same thing over and over again. In this post we would be understanding exactly that. Algorithmic paradigms are a way to solve a problem, and recursion is one of them. Some of the other ways are: Brute Force Divide and Conquer Greedy Dynamic Programming So, what is Recursion? Sometimes a good image helps to…

Time complexity is an important criteria when determining the quality of an algorithm. An algorithm is better if it produces the same result in a less time for the same input test cases. However, one must take care of the type of input data used. Some input data can give you false positives. Let us take an example to understand this better. You have an algorithm that is sorts a list of numbers. If the input data you provide to this algorithm is already sorted. Then this algorithm gives you…