Programming Articles - Page 2389 of 3366

Alternate Lower Upper String Sort in C++

Nishu Kumari
Updated on 29-Jul-2025 14:28:24

623 Views

We are given a string that contains both lowercase and uppercase characters, and we have to sort them in an alternate way, meaning one lowercase letter, then one uppercase letter, then again a lowercase letter, and so on, all in sorted order within their cases. Let's understand this with a few example scenarios. Scenario 1 Input: "aFegrAfStRzsV" Output: "AagfRsSeTvz" Explanation: Sorted uppercase letters: A, F, R, S, T, V Sorted lowercase letters: a, e, f, g, r, s, z We place one uppercase letter, then one lowercase letter, starting with an uppercase. We repeat this until all letters ... Read More

Alternate bits of two numbers to create a new number in C++

Nishu Kumari
Updated on 28-Jul-2025 19:26:34

250 Views

Here, we are given two numbers, and we have to create a new number by combining their bits in an alternating way. We take the first bit from the second number, the second bit from the first number, the third bit from the second again, and so on. We start from the least significant bit and continue until all bits from both numbers are used. Let's look at a few example scenarios to understand the problem clearly: Scenario 1: Input: First_number = 8, Second_number = 9 Output: 9 Explanation: Binary of 8 = 1000, Binary of 9 = ... Read More

Almost Perfect Number in C++

Manisha Chand
Updated on 31-Jul-2025 15:23:45

259 Views

Almost Perfect Number in C++ Almost Perfect Number is a positive integer n for which the sum of all its positive proper divisors (excluding the number itself ) is equal to n-1. (i.e., one less than the number n). It is also known as the least deficient number or slightly defective number. A positive proper divisor is a divisor of a number, excluding the number itself. For example, for n = 6; 1, 2, 3 are positive proper divisors but 6 itself is not. In Mathematics, we say A number n is almost perfect if: σ(n)-n = n-1 by ... Read More

Allocate minimum number of pages in C++

sudhir sharma
Updated on 16-Oct-2019 07:18:39

502 Views

Allocate a minimum number of pages is a programming problem. Let's discuss this problem in detail and see what can be the solution to it.StatementYou are given the number of pages of n different books. Also, there are m students to whom the books are to be assigned. The books are arranged in ascending order of the number of pages. And every student can be assigned some consecutive books. The program should return the maximum number of pages read by a student which should be minimum.Let's take an example to understand this problem in a better way, Input : books[] ... Read More

Arc function in C

sudhir sharma
Updated on 16-Oct-2019 07:12:56

3K+ Views

In the C programming language, there is an option to create an arc of a circle of a given radius with a given center coordinates and degree of the arc.The arc() function is used to create an arc. This arc function is included in graphics.h library in C which contains methods that can draw figures on the output screen.Syntaxvoid arc(int x, int y, int startangle, int endangle, int radius);Now, let's get deep into the function and understand each parameter passed and output returned by the function.Parametersx − type = int, function: defines the x coordinate of the center of the arc.y ... Read More

Alternate Fibonacci Numbers in C++

Nishu Kumari
Updated on 04-Aug-2025 16:24:15

734 Views

The Fibonacci sequence starts from 0 and 1, and each number is the sum of the previous two. In this problem, we are given a number n, and we need to print the first n numbers from the Fibonacci series, but only the numbers at alternate positions (like 0th, 2nd, 4th, and so on). Let's look at some example scenarios to understand it clearly: Scenario 1 Input: n = 7 Output: 0 1 3 8 Explanation: The first 7 Fibonacci numbers are 0 1 1 2 3 5 8. If we pick alternate numbers (index 0, 2, ... Read More

Alignof operator in C++

Akansha Kumari
Updated on 22-Aug-2025 15:22:29

796 Views

C++ alignof() Operator The alignof operator is the operator that returns the memory alignment for a given variable type. This alignment tells how the data is arranged and accessed in memory. It returns the value in bytes and is the part of the header file in C++. which is mainly used for low-level programming like memory management or hardware requirements. Syntax Here is the following syntax of alignof operator, which returns memory alignment required for a given data type in bytes: alignof(data_type) Example Demonstrating Usage of alignof() Operator Here is the following example code of using alignof() operator ... Read More

How to deserialize a JSON string using @JsonCreator annotation in Java?

raja
Updated on 17-Feb-2020 08:18:20

997 Views

The @JsonProperty annotation can be used to indicate the property name in JSON. This annotation can be used for a constructor or factory method. The @JsonCreator annotation is useful in situations where the @JsonSetter annotation cannot be used. For instance, immutable objects do not have any setter methods, so they need their initial values injected into the constructor.@JsonProperty - ConstructorExampleimport com.fasterxml.jackson.annotation.*; import java.io.IOException; import com.fasterxml.jackson.databind.*; public class JsonCreatorTest1 {    public static void main(String[] args) throws IOException {       ObjectMapper om = new ObjectMapper();       String jsonString = "{\"id\":\"101\", \"fullname\":\"Ravi Chandra\", \"location\":\"Pune\"}";       System.out.println("JSON: " + jsonString);   ... Read More

Advanced master theorem for divide and conquer recurrences

sudhir sharma
Updated on 08-Jun-2020 05:44:13

3K+ Views

Divide and conquer is an algorithm that works on the paradigm based on recursively branching problem into multiple sub-problems of similar type that can be solved easily.ExampleLet’s take an example to learn more about the divide and conquer technique −function recursive(input x size n)    if(n < k)       Divide the input into m subproblems of size n/p.       and call f recursively of each sub problem    else       Solve x and returnCombine the results of all subproblems and return the solution to the original problem.Explanation − In the above problem, the problem ... Read More

Virtual Copy Constructor in C++

sudhir sharma
Updated on 16-Oct-2019 06:32:23

7K+ Views

Before digging deep into the topics lets brush up all the related terms.A copy constructor is a special type of constructor that is used to create an object that is an exact copy of the object that is passed.A virtual function is a member function that is declared in the parent class and is redefined ( overridden) in a child class that inherits the parent class.With the use of a virtual copy constructor, the programmer will be able to create an object without knowing the exact data type of the object.In C++ programming language, copy Constructor is used to creating ... Read More

Advertisements