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
Server Side Programming Articles - Page 2157 of 2650
331 Views
In Python, a string is one of the data structures that is a sequence of characters enclosed within single quotes '' or double quotes "". It is immutable, i.e., once a string is created, it cannot be changed. When we want to check if both halves of the string have the same set of characters in Python, we can follow the steps below - First, based on the length of the string, we have to split the string into two halves. Next, convert each half into a set of characters using set() function. Finally, compare the two sets using ... Read More
1K+ Views
In this article, we will solve the problem of checking balanced parentheses. Let's understand the problem statement, The following are the conditions for balanced parentheses − Every opening parenthesis has a corresponding closing parentheses. Parentheses should be closed in the correct order. For example, "{[()]}" is a balanced parenthesis. condiser the same example with different arrangment "{([})]" which is unbalanced parantheses. Checking parentheses Using 'list' and 'for' loop list is one of the built-in data types in Python. A Python list is a sequence of comma-separated items, enclosed ... Read More
837 Views
Here we will see one problem. Suppose one array arr is given. We have to check whether the array can be split into two parts, such that −Sub of both sub-arrays will be the sameAll elements, which are multiple of 5, will be in the same groupAll elements which are multiple of 3, but not multiple of 5, will be in the same groupAll other elements will be in other groups.Suppose the array elements are {1, 4, 3}, then this can be split, because the sum of {1, 3} is the same as the sum of {4}, and the groups ... Read More
1K+ Views
A polygon is a closed two-dimensional shape formed by connecting three or more straight lines end-to-end. These lines form sides, and their connection points are called vertices. When the vertices of the polygon are given in a specific order either clockwise or counter-clockwise, we can calculate the area of the polygon using a mathematical formula known as the Shoelace Formula or Surveyor’s Formula. You are given the coordinates of a polygon with n vertices. The vertices are provided in an ordered manner, meaning they are listed either in clockwise or anticlockwise order starting from the first vertex to the last. ... Read More
1K+ Views
A regular polygon with n sides is a two-dimensional shape with n equal-length sides and n equal interior angles. It is both equilateral and equiangular (all sides are equal and all angles are equal). In the above diagram, we see that the polygon can be divided into n equal triangles. For one of the triangles, the complete angle at the center can be divided into = 2pi/n So, angle t = pi/n Now, tan(t) = a/2*h So, h = a/(2*tan(t)) Area of ... Read More
805 Views
Sorting the elements of an integer array in such a way that the first element is the maximum of the array and the second element of the sorted array is the minimum, the third one is the second minimum, the fourth one is the second maximum of the array and goes on.Let’s take an example to understand the concept better, Input : 4 1 8 2 9 3 7 Output : 9 1 8 2 7 3 4 Explanation : The elements in a sorted way is 1 2 3 4 7 8 9. Now, let’s create it in ... Read More
348 Views
A linked list is a linear data structure that stores elements and also stores a pointer to the next data node.In this problem on the sorting of a linked list, the alternate sort means sorting in such a way that the 1st node contains data with the minimum value, the 2nd node contains data with maximum value, 3rd with the next minimum (second minimum value) and so on. This pattern of alternate maxima and minimas is created in alternate sorting of linked lists.Let’s take an example to understand the problem better −Input : 3 > 4 > 21 >67 > ... Read More
371 Views
Given a singly linked list, we need to rearrange its nodes so that even and odd numbers come one after the other alternatively. If the list starts with an even number, the next should be odd, then even, and so on. Similarly, if it begins with an odd number, the next should be even, then odd, and so on. Let's look at some example scenarios to understand the concept better. Scenario 1 Input: 45 -> 21 -> 2 -> 213 -> 3 -> 34 -> 78 -> 12 Output: 45 -> 2 -> 21 -> 34 -> 213 -> 78 ... Read More
619 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
248 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