Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 4 of 196

How to move all the zeros to the end of the array from the given array of integer numbers using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 797 Views

Moving zeros to the end of an array is a common programming problem that can be solved efficiently using a two-pointer approach. The algorithm maintains the relative order of non-zero elements while shifting all zeros to the end of the array. Algorithm Overview The solution uses a single pass through the array with two pointers − Write Pointer − tracks the position where the next non-zero element should be placed Read Pointer − traverses through all elements in the array Time Complexity − O(N) where N is the array length Space Complexity − O(1) ...

Read More

How do I overload the [] operator in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 393 Views

The indexer ([] operator) in C# allows an object to be accessed like an array using square bracket notation. When you define an indexer for a class, instances of that class behave like virtual arrays, enabling array-style access using the [] operator. Indexers can be overloaded with different parameter types and counts. The parameters don't have to be integers — you can use strings, multiple parameters, or any other type as the index. Syntax Following is the basic syntax for defining an indexer − public returnType this[indexType index] { get { ...

Read More

How to check whether the given strings are isomorphic using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 1K+ Views

Two strings are called isomorphic if there exists a one-to-one character mapping between them. This means each character in the first string maps to exactly one character in the second string, and no two characters can map to the same character. The mapping must be consistent throughout both strings. For example, "egg" and "add" are isomorphic because 'e' maps to 'a', and 'g' maps to 'd'. However, "foo" and "bar" are not isomorphic because 'o' would need to map to both 'a' and 'r'. Algorithm Approach The solution uses two arrays to track the last seen position ...

Read More

How to Deserializing JSON to .NET object using Newtonsoft json in C# and pick only one value from the array?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 649 Views

JSON deserialization is the process of converting JSON data into .NET objects. The Newtonsoft.Json library (also known as Json.NET) provides powerful methods to deserialize JSON strings into strongly-typed C# objects. When working with JSON arrays, you can easily pick specific values from the deserialized array. Syntax Following is the syntax for deserializing JSON to a .NET object − T obj = JsonConvert.DeserializeObject(jsonString); For deserializing JSON arrays − T[] objArray = JsonConvert.DeserializeObject(jsonString); Using WebClient to Fetch and Deserialize JSON The WebClient class provides methods for downloading data from web resources. ...

Read More

How to find the length of the longest substring from the given string without repeating the characters using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 1K+ Views

The longest substring without repeating characters problem can be efficiently solved using the sliding window technique with two pointers. This approach maintains a window of unique characters and expands or contracts it based on whether duplicates are found. Algorithm Overview The sliding window technique uses two pointers i (left) and j (right) to maintain a window of unique characters. When a duplicate character is encountered, the left pointer moves forward to exclude the duplicate, while the right pointer continues expanding the window. Sliding Window Technique ...

Read More

How to find the length of the longest continuous increasing subsequence from an array of numbers using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 989 Views

The Longest Continuous Increasing Subsequence problem finds the length of the longest subarray where elements are in strictly increasing order. This algorithm uses a single pass through the array to track the current sequence length and maintains the maximum length found so far. The approach uses two variables: count to track the current increasing sequence length and res to store the maximum length encountered. When an element breaks the increasing pattern, the count resets to 1. Algorithm Explanation The algorithm works as follows − Initialize count = 1 and res = 1 to handle ...

Read More

How to implement Fibonacci using topDown approach using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 926 Views

The Fibonacci sequence is a set of numbers that starts with a one or a zero, followed by a one, and proceeds based on the rule that each number (called a Fibonacci number) is equal to the sum of the preceding two numbers. The top-down approach focuses on breaking down a big problem into smaller and understandable chunks using memoization to store previously computed values. This approach uses recursion with an additional array to cache results, avoiding redundant calculations and significantly improving performance over naive recursion. Complexity Analysis Time complexity − O(N) because each Fibonacci number is ...

Read More

How to use "not in" query with C# LINQ?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 7K+ Views

In C# LINQ, there are several ways to perform "not in" queries to exclude items from one collection that exist in another. The most common approaches use the Except operator, the Where clause with Any, or the Contains method. These operators work with any data source that implements IEnumerable, making them versatile for querying collections, arrays, and LINQ query results. Syntax Using the Except operator − var result = collection1.Except(collection2); Using Where with Any − var result = from item in collection1 ...

Read More

How to implement minimum step to one using topDown approach using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 198 Views

The minimum steps to one problem asks: given a positive integer n, find the minimum number of steps to reduce it to 1 using these operations − If n is divisible by 3, divide it by 3 If n is divisible by 2, divide it by 2 Subtract 1 from n The top-down approach uses recursion with memoization to solve this problem efficiently by storing computed results in a DP array. How It Works The algorithm recursively explores all possible operations at each step and chooses the one that gives the minimum result. Memoization ...

Read More

How to rethrow InnerException without losing stack trace in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 1K+ Views

In C#, rethrowing exceptions while preserving the complete stack trace is crucial for effective debugging. When handling exceptions, you have several options for rethrowing that affect how much debugging information is preserved. The key difference lies between using throw; (which preserves the full stack trace) versus throw ex; (which resets the stack trace to the current location). Additionally, when dealing with InnerException, you need special techniques to maintain the complete exception chain. Syntax Following is the syntax for rethrowing an exception without losing stack trace − try { // code that might ...

Read More
Showing 31–40 of 1,958 articles
« Prev 1 2 3 4 5 6 196 Next »
Advertisements