
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

186 Views
Suppose we have a 2d binary matrix, where 1 represents a bomb and 0 represents an empty cell. When a bomb explodes, all the spaces along on the same row and column are damaged. We have to find the number of spaces we can stand in to not get damaged.So, if the input is like110000000then the output will be 2, as there are two spaces the bottom right cell and the middle right cell are safe.To solve this, we will follow these steps:r := a list of size same as row count of matrix and fill with falsec := a ... Read More

130 Views
Suppose we have a list of numbers called nums and another value k. We have to following operation k times: Select any number on the list. In the binary representation of that number, select a bit that is 0 and make it 1. Finally, we have to return the minimum possible sum of all the numbers after performing k operations. If the answer is too high, return result mode 10^9+7.So, if the input is like nums = [4, 7, 3] k = 2, then the output will be 17, as the binary representation of 4 is 100, 3 is 011, ... Read More

93 Views
Suppose we have n children standing in a circle, and they are waiting to get a balloon. The distribution is carried out starting with the kth child (first at index 0), and giving them a balloon they left the circle. Now every kth child gets a balloon going clockwise until there is only one child left that gets a balloon. So if we have n and k, we have to find the starting index of the child that receives the last balloon.So, if the input is like n = 3 k = 2, then the output will be 1, in ... Read More

640 Views
A Binary Search Tree is a data structure that stores data in a sorted order such that for every node, the left subtree contains values less than the node's value, and the right subtree contains values greater than the node's value. In this article, we will discuss how to convert a Binary Search Tree (BST) into a singly linked list in C++. Flatten Binary Search Tree to Singly Linked List Given a Binary Search Tree, the goal is to convert it into a singly linked list where the linked list nodes are in the same order as the in-order ... Read More

181 Views
Suppose we have a number n; we have to find the smallest next higher number with the same number of 1s as n in binary form.So, if the input is like n = 7, then the output will be 11, as 7 in binary is 0111 and next higher from 7 with three ones would be 11 which is 1011 in binary.To solve this, we will follow these steps:copy := n, zeros := 0, ones := 0while copy is not 0 and copy is even, dozeros := zeros + 1copy = copy / 2while copy is odd, doones := ones ... Read More

241 Views
Suppose we have a 2D binary matrix. Here each row is sorted in ascending order with 0s coming before 1s, we have to find the leftmost column index with the value of 1. If there's no such result, return -1.So, if the input is like0001001100110010then the output will be 2, as the second column has left most 1 in entire matrix.To solve this, we will follow these steps:if matrix is empty, thenreturn -1N := row count of matrixM := column count of matrixi := 0, j := M - 1leftmost := -1while i < N and j >= 0, doif ... Read More

203 Views
Suppose we have a list of stock prices of a company in chronological order, we have to find the maximum profit we could have made from buying and selling the stock. We must buy before selling, and we must wait one day after selling the stock before buying again.So, if the input is like prices = [2, 6, 9, 4, 11], then the output will be 11, as we can buy at 2, then sell at 6, wait for a day, then buy at 4 and then sell at 11.To solve this, we will follow these steps:s := 0b := ... Read More

165 Views
Suppose we have a singly linked list, we have to rearrange it such that we take: the last node, and then the first node, and then the second last node, and then the second node, and so on.So, if the input is like [1, 2, 3, 4, 5, 6, 7, 8, 9], then the output will be [9, 1, 8, 2, 7, 3, 6, 4, 5, ]To solve this, we will follow these steps:c := nodel := a new listwhile c is not-null, doinsert value of c at the end of lc := next of cc := nodewhile c is ... Read More

891 Views
Suppose we have a string s consisting only two letters A and B, we have to find the minimum number of letters that need to be deleted from s to get all occurrences of As before all occurrences of Bs.So, if the input is like S = "AABAABB", then the output will be 1, as We can remove the last A to get AABBBTo solve this, we will follow these steps:a_right := number of occurrences of "A" in sb_left := 0ans := a_rightfor each index i and character c in s, doif c is same as "A", thena_right := a_right ... Read More

168 Views
Suppose we have a list of non-negative numbers called nums and also have an integer target. We have to find the the number of ways to arrange + and - in nums such that the expression equals to target.So, if the input is like nums = [2, 3, 3, 3, 2] target = 9, then the output will be 2, as we can have -2 + 3 + 3 + 3 + 2 and 2 + 3 + 3 + 3 – 2.To solve this, we will follow these steps:s := sum of all numbers in numsif (s + target) ... Read More