Articles on Trending Technologies

Technical articles with clear explanations and examples

Generate Parentheses in Python

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

Generating well-formed parentheses is a classic programming problem that involves creating all valid combinations of opening and closing parentheses for a given number n. For n=3, we need 3 opening and 3 closing parentheses arranged in valid patterns. Problem Understanding A valid parentheses combination follows these rules ? Equal number of opening '(' and closing ')' parentheses At any point, the number of closing parentheses should not exceed opening ones All opening parentheses must be properly closed Solution Approach We use a recursive backtracking approach with these steps ? Track the ...

Read More

Remove Nth Node From End of List in Python

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

Removing the Nth node from the end of a linked list is a common programming problem. Given a linked list and a number n, we need to remove the node that is n positions from the end and return the modified list head. For example, if we have a list [1, 2, 3, 4, 5, 6] and n = 3, we remove the 3rd node from the end (which is 4), resulting in [1, 2, 3, 5, 6]. Algorithm Steps We use a two-pointer approach to solve this efficiently ? If there is only one ...

Read More

Letter Combinations of a Phone Number in Python

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

The Letter Combinations of a Phone Number problem involves generating all possible letter combinations that a string of digits (2-9) could represent on a phone keypad. Each digit maps to a set of letters, similar to old telephone keypads. Phone Keypad Mapping 1 2abc 3def 4ghi 5jkl 6mno 7pqrs 8tuv 9wxyz * 0 # For example, if the input is "23", the possible combinations are ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]. Algorithm Approach We'll use backtracking to solve this problem: ...

Read More

3Sum in Python

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

The 3Sum problem asks us to find all unique triplets in an array that sum to zero. Given an array of integers, we need to identify three elements a, b, c such that a + b + c = 0. For example, in array [-1, 0, 1, 2, -1, -4], the triplets [[-1, -1, 2], [-1, 0, 1]] satisfy this condition. Algorithm Approach We use the two-pointer technique with these steps ? Sort the array to enable two-pointer approach Fix one element and use two pointers for the remaining two elements Skip duplicates to ensure unique ...

Read More

Container With Most Water in Python

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

The Container With Most Water problem asks us to find two vertical lines that can hold the maximum amount of water. Given an array of heights, we need to find two positions that form a container with the largest area. Problem Understanding Given an array of non-negative integers where each value represents the height of a vertical line, we need to find two lines that together with the x-axis form a container that can hold the most water. The area is calculated as width × minimum_height. Container With Most Water ...

Read More

Regular Expression Patterns in Python

Mohd Mohtashim
Mohd Mohtashim
Updated on 25-Mar-2026 592 Views

Regular expressions are patterns used to match character combinations in strings. In Python, most characters match themselves, except for special control characters (+ ? . * ^ $ ( ) [ ] { } | \) which have special meanings. You can escape these control characters by preceding them with a backslash. The following table lists the regular expression syntax available in Python ? Pattern Description Example ^ Matches beginning of line ^Hello matches "Hello world" $ Matches end of line world$ matches "Hello world" . Matches ...

Read More

Regular Expression Modifiers in Python

Mohd Mohtashim
Mohd Mohtashim
Updated on 25-Mar-2026 2K+ Views

Regular expression modifiers (also called flags) are optional parameters that control how pattern matching behaves. You can combine multiple modifiers using the bitwise OR operator (|) to customize the search behavior. Common Regular Expression Modifiers Modifier Name Description re.I IGNORECASE Performs case-insensitive matching re.M MULTILINE Makes ^ and $ match start/end of each line re.S DOTALL Makes dot (.) match any character including newline re.X VERBOSE Ignores whitespace and allows comments in patterns re.L LOCALE Uses locale-aware matching (deprecated) re.U UNICODE ...

Read More

Data Hiding in Python

Sarika Singh
Sarika Singh
Updated on 25-Mar-2026 7K+ Views

Data hiding is also known as data encapsulation and it is the process of hiding the implementation of specific parts of the application from the user. Data hiding combines members of class thereby restricting direct access to the members of the class. Data hiding plays a major role in making an application secure and more robust. Data Hiding in Python Data hiding in Python is a technique of preventing methods and variables of a class from being accessed directly outside of the class in which the methods and variables are initialized. Data hiding of essential member functions ...

Read More

Overloading Operators in Python

Mohd Mohtashim
Mohd Mohtashim
Updated on 25-Mar-2026 636 Views

In Python, you can customize how operators work with your custom classes through operator overloading. This is achieved by defining special methods (also called magic methods) in your class that correspond to specific operators. Suppose you have created a Vector class to represent two-dimensional vectors, what happens when you use the plus operator to add them? Most likely Python will yell at you. You could, however, define the __add__ method in your class to perform vector addition and then the plus operator would behave as per expectation ? Example class Vector: ...

Read More

Base Overloading Methods in Python

Mohd Mohtashim
Mohd Mohtashim
Updated on 25-Mar-2026 478 Views

Python provides special methods (also called magic methods or dunder methods) that you can override in your classes to customize their behavior. These methods allow your objects to work seamlessly with built-in functions and operators. Common Base Overloading Methods Sr.No. Method, Description & Sample Call 1 __init__(self [, args...])Constructor method called when creating an objectSample Call: obj = ClassName(args) 2 __del__(self)Destructor method called when object is garbage collectedSample Call: del obj 3 __repr__(self)Returns unambiguous string representation for developersSample Call: repr(obj) 4 __str__(self)Returns human-readable string representationSample ...

Read More
Showing 1–10 of 61,304 articles
« Prev 1 2 3 4 5 6131 Next »
Advertisements