Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 2 of 196

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 989 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 647 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 982 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 921 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 194 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

How to set a property value by reflection in C#?

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

The System.Reflection namespace in C# provides classes that allow you to obtain information about applications and dynamically add types, values, and objects at runtime. One of the most common uses of reflection is setting property values dynamically when you don't know the property name at compile time. Reflection allows you to examine various types in an assembly, instantiate these types, perform late binding to methods and properties, and even create new types at runtime. Syntax Following is the syntax for setting a property value using reflection − Type type = obj.GetType(); PropertyInfo property = type.GetProperty("PropertyName"); ...

Read More

How to implement coin change problem using bottom-up approach using C#?

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

The coin change problem is a classic dynamic programming challenge where we need to find the minimum number of coins required to make a given amount. The bottom-up approach builds solutions incrementally, starting from the smallest amounts and working up to the target amount. This approach uses dynamic programming to avoid recalculating the same subproblems multiple times, storing previously computed results in an array. Time complexity − O(n × t) where n is the amount and t is the number of coin types Space complexity − O(n) for the dynamic programming array Syntax Following is the ...

Read More
Showing 11–20 of 1,958 articles
« Prev 1 2 3 4 5 196 Next »
Advertisements