Server Side Programming Articles

Page 528 of 2109

Program to count number of elements are placed at correct position in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 416 Views

Suppose we have a list of numbers called nums, we have to find the number of elements that are present in the correct indices, when the list was to be sorted. So, if the input is like [2, 8, 4, 5, 11], then the output will be 2, as the elements 2 and 11 are in their correct positions. The sorted sequence will be [2, 4, 5, 8, 11] Algorithm To solve this, we will follow these steps − s := sort the list nums count := 0 for i in range 0 to size ...

Read More

Program to check whether we can stand at least k distance away from the closest contacts in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 142 Views

Suppose we have a string s and a number k. Each character in the string is either a dot ('.') or 'x', where dot indicates an empty space and 'x' indicates a person. We need to check whether it's possible to choose a position to stand on such that the distance between us and the closest person is at least k units away. The distance between neighboring indices is 1. For example, if the input is s = "x...x.." and k = 2, the output will be True because we can stand at position s[2] or s[6]. Algorithm ...

Read More

Program to find shortest sublist so after sorting that entire list will be sorted in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 298 Views

Sometimes we need to find the shortest sublist that, when sorted, makes the entire list sorted. This problem involves comparing the original list with its sorted version to identify the boundaries of the unsorted region. So, if the input is like nums = [1, 2, 5, 4, 9, 10], then the output will be 2, as sorting the sublist [5, 4] would make the entire list sorted: [1, 2, 4, 5, 9, 10]. Algorithm To solve this, we will follow these steps − Initialize first := -1, last := -1 to track the boundaries Create ...

Read More

Program to find shortest string after removing different adjacent bits in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 391 Views

Suppose we have a binary string s, we can delete any two adjacent letters if they are different. Finally, we have to find the length of the smallest string that we can get if we are able to perform this operation as many times as we want. So, if the input is like s = "1100011", then the output will be 1, as after deleting "10" we get "10011", then again delete "10", it will be "011", then delete "01", it will have left "1". Algorithm Approach To solve this, we will follow these steps − ...

Read More

Program to encode a string in normal form to its run-length form in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 565 Views

Run-length encoding is a simple compression technique that replaces consecutive identical characters with a count followed by the character. For example, "AAABBC" becomes "3A2B1C". So, if the input is like s = "BBBBAAADDCBB", then the output will be "4B3A2D1C2B". Algorithm To solve this, we will follow these steps − Initialize an empty result string Set tmp to the first character and count to 1 Iterate through the string starting from index 1 If current character differs from tmp, append ...

Read More

Program to decode a run-length form of string into normal form in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 2K+ Views

Suppose we have a string s. The s is a run-length encoded string, we have to find the decoded version of it. As we know, run-length encoding is a fast and simple method of encoding strings. The idea is as follows − The repeated successive elements (characters) as a single count and character. For example, if the string is like "BBBBAAADDCBB" would be encoded as "4B3A2D1C2B". So, if the input is like s = "4B3A2D1C2B", then the output will be "BBBBAAADDCBB" Algorithm To solve this, we will follow these steps ? ...

Read More

Program to find how many distinct rotation groups are there for a list of words in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 362 Views

Suppose we have a rotation group for a string that holds all of its unique rotations. If the input is like "567" then this can be rotated to "675" and "756" and they are all in the same rotation group. Now if we have a list of strings words, we have to group each word by their rotation group, and find the total number of groups. So, if the input is like words = ["xyz", "ab", "ba", "c", "yzx"], then the output will be 3, as there are three rotation groups − ["xyz", "yzx"], ["ab", "ba"], ["c"]. Algorithm ...

Read More

Program to check whether every rotation of a number is prime or not in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 777 Views

In this problem, we need to check if all possible rotations of a given number are prime numbers. A rotation means moving digits from the front to the back or vice versa. So, if the input is like n = 13, then the output will be True, as 13 is prime and its rotation 31 is also prime. Algorithm To solve this, we will follow these steps − Convert the number to string format For each possible rotation of the number: Check if the current rotation is prime If any rotation is not prime, ...

Read More

Malicious QR Code with QRGen

Ajay yadav
Ajay yadav
Updated on 25-Mar-2026 1K+ Views

QR codes are machine-readable data formats used across various applications, from product packaging to airline boarding passes. However, these convenient codes can be exploited by attackers who embed malicious payloads into custom QR codes using tools like QRGen. Since humans cannot read QR code content without scanning, malicious codes are difficult to identify before exposure, making QR code attacks particularly effective against vulnerable devices. QRGen is a Python tool that generates malicious QR codes by encoding various exploit payloads. It includes a built-in library of popular exploits, making it valuable for penetration testers auditing QR code scanners and security ...

Read More

Build Your Own Botnet

Ajay yadav
Ajay yadav
Updated on 25-Mar-2026 9K+ Views

BYOB (Build Your Own Botnet) is an educational framework designed for security researchers and developers to understand malware behavior and develop countermeasures. This Python-based tool helps create a controlled botnet environment for learning purposes. BYOB Architecture Command & Control Server (server.py) Bot Clients (testbot.py) Target Machines ...

Read More
Showing 5271–5280 of 21,090 articles
« Prev 1 526 527 528 529 530 2109 Next »
Advertisements