
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 7197 Articles for C++

171 Views
Suppose we have a list of numbers called nums and another value k, we have to check whether it is possible to partition nums into k different subsets where the sum of each subset are same.So, if the input is like nums = [4, 2, 6, 5, 1, 6, 3] k = 3, then the output will be True, as we can partition them like: [6, 3], [6, 2, 1], and [4, 5].To solve this, we will follow these steps −Define a function check(), this will take an array v, for initialize i := 1, when i < size of ... Read More

215 Views
Suppose we have a list of numbers called nums, and another value k, we have to find the k non-overlapping, non-empty sublists such that the sum of their sums is maximum. We can consider k is less than or equal to the size of nums.So, if the input is like nums = [11, -1, 2, 1, 6, -24, 11, -9, 6] k = 3, then the output will be 36, as we can select the sublists [11, -1, 2, 1, 6], [11], and [6] to get sums of [19, 11, 6] = 36.To solve this, we will follow these steps ... Read More

102 Views
Suppose we have an list of words and a width k, we have to arrange the text such that each line has exactly k number of characters and the text is fully justified. Here we shall pack our words as many words as we can insert in each line. And we shall pad extra spaces ' ' when necessary so that each line has exactly k characters.Here extra spaces between words should be distributed as evenly as possible. If the number of spaces on a line do not divide evenly between words, empty slots on the left will be assigned ... Read More

189 Views
Suppose we have a list of numbers called jobs and another value k. Now we want to finish all jobs in k different days. The jobs must be performed in the given order and in each day we have to complete one task. The difficulty of job i is stored at jobs[i] and the difficulty of completing a list of jobs on a day will be the maximum difficulty job performed on that day. So we have to find the minimum sum of the difficulties to perform the jobs over k different days.So, if the input is like jobs = ... Read More

346 Views
Suppose we have a string with only digits, we have to restore it by forming all possible valid IP address combinations. We know that a valid IP address consists of exactly four integers (each integer is in range 0 to 255) separated by single period symbol.So, if the input is like ip = "25525511136", then the output will be ["254.25.40.123", "254.254.0.123"]To solve this, we will follow these steps −Define a function convertToNum(), this will take s, start, end, num := 0for initialize i := start, when i 255, then −return 10000return numDefine a function addDots(), this will take positions, ... Read More

313 Views
Suppose we have a list of intervals of the form [start, end] this is representing the starts and end points of banners we want to hang. At least one pin is required to hang a banner, and one pin can hang more than once banners. We have to find the smallest number of pins required to hang all the banners.So, if the input is like intervals = [[2, 5], [5, 6], [8, 10], [10, 13]], then the output will be 2, as we can put two pins at position 5 and 10 to hang all of the banners.To solve this, ... Read More

117 Views
Suppose we have an edge list for an undirected graph where each edge has [u, v, w] fields, u and v are source and destination vertices and w is the weight. And also have a list of queries of the same form [u, v, w]. That represents the question of does there exist a path between u and v such that each edge in the path have weight of at most w. So find the number of queries that are true.So, if the input is like edges = [[0, 1, 6], [1, 2, 7], [2, 3, 8], [0, 3, 5]] ... Read More

190 Views
Suppose we have a list of words. Now consider a ghost game where two players can participate into it. Here players alternate appending letters to a string. And the string that is being made must be a valid prefix of a word in the list, and the player who spells out any word in the list loses. We have to check whether the first player can win or not if both players are playing optimally.So, if the input is like words = ["manage", "manager", "min"], then the output will be True, as they can play like −m [Player 1]ma [Player ... Read More

217 Views
Suppose we have two strings S and T. We have to find the shortest sequence of operations that changes S to T. Here the operations are basically either deleting or inserting a character.So, if the input is like S = "xxxy" T = "xxyy", then the output will be ["x", "x", "-x", "y", "+y"], this means place first two x's, then remove 3rd x, then place y then add a new y.To solve this, we will follow these steps −make a table dp of size 505 x 505Define a function help(), this will take i, j, S, T, if i ... Read More

418 Views
Suppose we have two numbers called numerator and denominator representing a rational number in the form (numerator / denominator). We have to find its decimal representation as a string. If there are some recurring numbers, then surround them with brackets.So, if the input is like numerator = 164 denominator = 3, then the output will be "54.(6)".To solve this, we will follow these steps −if numerator is same as 0, then −return "0"Define an array ansif numerator < 0 and denominator > 0 or numerator > 0 and denominator < 0, then −insert '-' at the end of ansdivisor := ... Read More