Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
Program to find total amount of money we have in bank in Python
Suppose you put 1Rs in a bank on the first day (Monday). Each subsequent day of the week, you put in 1Rs more than the previous day. On every new Monday, you start with 1Rs more than the previous Monday. This creates a pattern where the amount increases both daily and weekly. For example, if n = 17 days: Week 1: 1Rs (Mon) + 2Rs (Tue) + 3Rs (Wed) + 4Rs (Thu) + 5Rs (Fri) + 6Rs (Sat) + 7Rs (Sun) = 28Rs Week 2: 2Rs (Mon) + 3Rs (Tue) + 4Rs (Wed) + 5Rs (Thu) + 6Rs ...
Read MoreProgram to find maximum units that can be put on a truck in Python
Suppose we have a set of boxes represented as a 2D array called boxTypes, where boxTypes[i] contains two elements [number of boxes of type i, number of units per box of type i]. Now we also have another value k, which is the maximum number of boxes that can be put on that truck. We can select any boxes to put on the truck as long as the number of boxes does not cross k. We have to find the maximum total number of units that can be put on the truck. Problem Understanding So, if the input ...
Read MoreProgram to check whether String Halves Are Alike in Python
Suppose we have a string s whose length is even. We have to split this string into two different halves of same lengths. So consider 'a' is the first half and 'b' is the second half. We say two strings are alike when they have the same number of vowels (uppercase or lowercase). We have to check whether 'a' and 'b' are alike or not. So, if the input is like s = "talent", then the output will be True because two halves are "tal" and "ent", they are alike because they have only one vowel each. Algorithm ...
Read MoreProgram to find reformatted phone number in Python
Phone number formatting is a common task in data processing. Given a phone number string containing digits, spaces, and dashes, we need to reformat it according to specific grouping rules. Problem Requirements The reformatting follows these rules: Remove all spaces and dashes first Group digits from left to right into blocks of 3 until 4 or fewer digits remain Handle the final digits based on count: 2 digits: Single block of length 2 3 digits: Single block of length 3 4 digits: Two blocks of length 2 each Join all blocks with dashes ...
Read MoreProgram to count number of matches played in tournament in Python
Suppose we have a number n representing the number of teams in a tournament. The tournament follows specific rules to determine matches and winners ? If the number of teams is even, each team gets paired with another team. A total of (n/2) matches are played, and (n/2) winner teams advance to the next round. If the number of teams is odd, one team randomly advances to the next round without playing. The remaining teams get paired, so (n-1)/2 matches are played, and (n-1)/2 + 1 teams advance as winners. ...
Read MoreProgram to count the number of consistent strings in Python
Suppose we have a string s consisting of distinct characters and also have an array of strings called words. A string is consistent when all characters in the string appear in the string s. We have to find the number of consistent strings present in the array words. So, if the input is like s = "px", words = ["ad", "xp", "pppx", "xpp", "apxpa"], then the output will be 3 because there are three strings with only 'p' and 'x': ["xp", "pppx", "xpp"]. Algorithm To solve this, we will follow these steps − ...
Read MoreProgram to find goal parser interpretation command in Python
Suppose we have a Goal Parser that can interpret a given string command. A command consists of: An alphabet "G" Opening and closing parenthesis "()" and/or "(al)" in some order Our Goal Parser will interpret "G" as the string "G", "()" as "o", and "(al)" as the string "al". Finally interpreted strings are then concatenated in the original order. Problem Statement Given a string command, we need to find the Goal Parser's interpretation of the command. For example, if the input is command = "G()()()(al)(al)", then the output will be "Goooalal". Approach ...
Read MorePython Program to find out the number of sets greater than a given value
Suppose we have an array containing several integer numbers. We need to find all contiguous subarrays, replace each subarray with its maximum element, and count how many of these maximum values are greater than a given number k. So, if the input is like input_array = [5, 6, 7, 8], k = 7, then the output will be 4. Understanding the Problem The contiguous subarrays from the given input array are: {5}, {6}, {7}, {8}, {5, 6}, {6, 7}, {7, 8}, {5, 6, 7}, {6, 7, 8}, {5, 6, 7, 8} If we replace each subarray ...
Read MorePython Program to find out the determinant of a given special matrix
Determinants of special matrices formed from tree structures have important applications in graph theory and computational mathematics. In this problem, we construct an n×n matrix A where each element A(x, y) equals the weight of the least common ancestor (LCA) of vertices x and y in a tree. Problem Understanding Given a tree with n vertices labeled 1 to n, where vertex 1 is the root and each vertex has weight wi, we need to find the determinant of matrix A where A(x, y) = weight_of_LCA(x, y). Example Tree Structure For input edges [[1, 2], [1, ...
Read MorePython Program to find out the number of rooms in which a prize can be hidden
Suppose in a game show there are 2n rooms arranged in a circle. One room contains a prize that participants must find. The rooms are numbered 1, 2, 3, ..., n, -n, -(n-1), ..., -1 in clockwise order. Each room has a door with a marking x that indicates the distance to the next room. If x is positive, the door opens to the xth room clockwise; if negative, it opens to the xth room counter-clockwise. We need to find how many rooms can hide the prize such that participants cannot find it by following the door sequence. ...
Read More