Server Side Programming Articles

Page 1282 of 2109

Maximum Vacation Days in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 504 Views

Suppose one company wants to give one of its best employees the option to travel among N cities to collect some resources. But employees want some vacations also, we could take vacations in some particular cities and weeks. Our task is to schedule the traveling to maximize the number of vacation days we could take, but there are certain rules and restrictions we have to follow.We can only travel among N cities; they are represented by indexes from 0 to N-1. Firstly, we are in the city indexed 0 on Monday.These cities are connected by flights. We have one N ...

Read More

Java Program for Stooge Sort

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 237 Views

Following is the Java program for Stooge sort −Exampleimport java.io.*; public class Demo {    static void stooge_sort(int my_arr[], int l_val, int h_val){       if (l_val >= h_val)       return;       if (my_arr[l_val] > my_arr[h_val]){          int temp = my_arr[l_val];          my_arr[l_val] = my_arr[h_val];          my_arr[h_val] = temp;       }       if (h_val-l_val+1 > 2){          int temp = (h_val-l_val+1) / 3;          stooge_sort(my_arr, l_val, h_val-temp);          stooge_sort(my_arr, l_val+temp, h_val);     ...

Read More

Maximum Average Subarray II in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 1K+ Views

Suppose we have an array with n integers, we have to find the contiguous subarray whose length is greater than or equal to k that has the maximum average value. We have to find the maximum average value.So, if the input is like [1, 12, -5, -6, 50, 3], k = 4, then the output will be 12.75, as when length is 5, maximum average value is 10.8, when length is 6, maximum average value is 9.16667. Thus output is 12.75.To solve this, we will follow these steps −Define a function ok(), this will take x, an array nums, k, ...

Read More

Java Program for Standard Normal Distribution (SND)

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 436 Views

Following is the Java program for Standard Normal Distribution −Exampleimport java.io.*; import java.util.*; public class Demo{    public static void main(String[] args){       double std_dev, val_1, val_3, val_2;       val_1 = 68;       val_2 = 102;       val_3 = 26;       std_dev = (val_1 - val_2) / val_3;       System.out.println("The standard normal deviation is: " + std_dev);    } }OutputThe standard normal deviation is: -1.3076923076923077A class named Demo contains the main function, where certain double values are defined, and the formula for standard deviation is applied ((val_1 - val_2) / val_3) on these values and the resultant output is displayed on the console.

Read More

Coin Path in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 318 Views

Suppose we have an array A (index starts at 1) with N numbers: A1, A2, ..., AN and another integer B. The integer B denotes that from any index is i in the array A, we can jump to any one of the places in the array A indexed i+1, i+2, …, i+B if this place can be jumped to. Also, if we step on the index i, we have to pay Ai amount of coins. If Ai is -1, it means we can’t jump to the place indexed i in the array.Now, when we start from the place indexed ...

Read More

Static Control Flow in Java

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 1K+ Views

The Static Control Flow identify static members, executes static blocks, and then executes the static main method. Let us see an example −Examplepublic class Demo{    static int a = 97;    public static void main(String[] args){       print();       System.out.println("The main method has completed executing");    }    static{       System.out.println(a);       print();       System.out.println("We are inside the first static block");    }    public static void print(){       System.out.println(b);    }    static{       System.out.println("We are inside the second static block");    }   ...

Read More

K Empty Slots in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 472 Views

Suppose we have N bulbs in a row and they are numbered from 1 to N. At first, all the bulbs are off. We can turn on exactly one bulb everyday until all bulbs are on after N days. If we have an array bulbs of length N where bulbs[i] = x this indicates that on the (i+1)th day, we will turn on the bulb at position x. If we have another integer K, such that out the minimum day number such that there exists two turned on bulbs that have exactly K bulbs between them that are all off. ...

Read More

Static method in Interface in Java

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 1K+ Views

To implement static method in Interface, the Java code is as follows −Exampleinterface my_interface{    static void static_fun(){       System.out.println("In the newly created static method");    }    void method_override(String str); } public class Demo_interface implements my_interface{    public static void main(String[] args){       Demo_interface demo_inter = new Demo_interface();       my_interface.static_fun();       demo_inter.method_override("In the override method");    }    @Override    public void method_override(String str){       System.out.println(str);    } }OutputIn the newly created static method In the override methodAn interface is defined, inside which a static function is defined. Another ...

Read More

Employee Free Time in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 622 Views

Suppose we have given a list of schedules of employees; this represents the working time for each employee. Now suppose each employee has a list of non-overlapping Intervals, these intervals are sorted. We have to find the list of finite intervals representing the common, positive-length free time for all employees, and that will also be in sorted order. We are representing Intervals in the form [x, y], For example, schedule [0][0].start = 1, schedule[0][0].end = 2.So, if the input is like schedule = [[[1, 2], [5, 6]], [[1, 3]], [[4, 10]]], then one of the output will be [[3, 4]].To ...

Read More

Basic Calculator III in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 960 Views

Suppose we have a simple expression string and we have to Implement a basic calculator to evaluate that expression. The expression string may contain opening and closing parentheses, the plus + or minus sign -, non-negative integers and empty spaces. The expression string contains only non-negative integers, +, -, *, / operators, opening and closing parentheses and empty spaces. The integer division should truncate toward zero.So, if the input is like "6-4 / 2", then the output will be 4To solve this, we will follow these steps −l1 := 0, l2 := 1o1 := 1, o2 := 1Define one stack ...

Read More
Showing 12811–12820 of 21,090 articles
Advertisements