
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

188 Views
In this problem, we are given two numbers x and y. Our task is to find larger of x^y and y^x. Problem Description: The problem is simple, we need to find weather x to the power y is greater than y to the power x.Let’s take an example to understand the problem, Input: x = 4, y = 5Output: 1024Explanation: x^y = 4^5 = 1024y^x = 5^4 = 625Solution ApproachThe solution to the problem is simple. We need to find the value of x^y and y^x and return the maximum of both.There can be a more mathematically easy way to solve the problem, which is ... Read More

187 Views
In this problem, we are given two integer values n and k. Our task is to find kth smallest number in range [1, n] when all the odd numbers are deleted. We need to find the kth smallest number in the range [1, n] which contains only even values.So, from range [1, 5] -> number will be 2, 4.Let’s take an example to understand the problem, Input: n = 12, k = 4Output: 8Explanation: Even elements in the range [1, n] : 2, 4, 6, 8, 10, 12The 4th smallest element is 8.Solution approach: The solution is simple as we need to find the kth ... Read More

461 Views
In this problem, we are given a linked-list and a number k. Our task is to find kth node from Middle towards the Head of a Linked List. Let’s take an example to understand the problem, Input: linked-list : 4 -> 2 -> 7 -> 1 -> 9 -> 12 -> 8 -> 10 -> 5, k = 2Output: 7Explanation: Middle node value is 9.The 2nd node from middle towards head is 7.Solution ApproachWe need to find kth element from the middle of the linked-list towards the beginning. For this we need to find the size of linked-list by traversing the linked-list from beginning ... Read More

351 Views
In this problem, we are given n ranges and an integer k. Our task is to find k-th smallest element in given n ranges. We need to find the kth smallest elements from the array which is created after combining the ranges.Let’s take an example to understand the problem, Input: ranges = {{2, 5}, {7, 9}, {12, 15}}, k = 9Output: 13Explanation: The array created is {2, 3, 4, 5, 7, 8, 9, 12, 13, 14, 15}The smallest elements is 13Solution Approach:A simple solution to the problem is by creating the array from all ranges and as it is created from range it is ... Read More

169 Views
In this problem, we are given an array arr[] of n elements. Our task is to find k maximum elements of the array in original order. We need to find k maximum elements of the array and then print then as they were indexed originally.Let’s take an example to understand the problem, Input: arr[] = {5, 1, 3, 6, 2}, k = 2Output: 5, 6Explanation: The largest two elements of the array are 6 and 5. But 5 comes before 6 in the original array hence we have printed in that way.Solution ApproachTo solve the problem, and print k elements in the original order.For ... Read More

128 Views
In this problem, we are given a list that consists of items and their values and an integer k. Our task is to find K items with the lowest values. Problem description: We need to find k items from the list that have the lowest value.Let’s take an example to understand the problem, Input: item-value = { {item1, 200}, {item2, 100}, {item3, 500}, {item4, 400}} k = 2Output: item1 , item2Explanation: Two elements with least value are item1 with 200 and item2 with 100.Solution ApproachA solution to the problem is by finding k items with the least value greedily. We will first sort the item ... Read More

411 Views
In this problem, we are given an array arr[] of n integers.Our task is to find integers that divides maximum number of elements of the array. Problem Description: We need to find a number p which can divide the maximum number of elements of the array. In case, there are more than one such element we will return the smaller one.Let’s take an example to understand the problem, Input: arr[] = {4, 5, 6, 7, 8}Output: 2Explanation: The element 2 divides {4, 6, 8}.Solution ApproachA simple solution to the problem is by looping through the array and then for each element of the array, divide each ... Read More

709 Views
In this problem, we are given two sorted arrays arr1 and arr2 of size n and n+1 with all elements the same except the extra element. Our task is to find index of an extra element present in one sorted array. Problem Description: We need to find the index of an element from the n+1 size array which is not present in an array of size n.Let’s take an example to understand the problem, Input: arr1[n] = {3, 5, 7, 8, 9, 12} arr2[n+1] = {3, 4, 5, 7, 8, 9, ... Read More

302 Views
In this problem, we are given four integers denoting the starting points and jumps taken by each in the race. Our task is to find if two people ever meet after same number of jumps. Problem Description: Here, we need to check if two persons starting at points p1 and p2 taking jumps j1 and j2 will be at some point in the path or not.Let’s take an example to understand the problem, Input: p1 = 5, p2 = 9, j1 = 4, j2 = 2Output: YesExplanation:After first jump, p1 = 9, p2 = 11After second jump, p1 = 13, p2 = 13Solution Approach: For ... Read More

168 Views
In this problem, we are given an array arr[] consisting of only 1 and -1 and an integer value k. Our task is to find if there is any subset of size K with 0 sum in an array of -1 and +1. Let’s take an example to understand the problem, Input: arr[] = {-1, 1, -1, -1, 1 , 1, -1}, k = 4Output: YESExplanation:Subset of size 4, {-1, 1, -1, 1}. Sum = -1 + 1 - 1 + 1 = 0Solution Approach: We need to check if there exists any subset of size k whose sum is equal to 0. As ... Read More