Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 6 of 196

How to rotate an array k time using C#?

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

Array rotation is a common programming problem where elements are shifted by k positions. When we rotate an array to the right by k positions, the last k elements move to the beginning, and the remaining elements shift right. For example, if we have array [1, 2, 3, 4, 5] and rotate it right by 2 positions, we get [4, 5, 1, 2, 3]. Algorithm The most efficient approach uses the reversal algorithm which works in three steps − Reverse the entire array Reverse the first k elements Reverse the remaining elements from position k ...

Read More

How to return the index of first unique character without inbuilt functions using C#?

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

Finding the index of the first unique character in a string is a common programming problem. The approach involves using a frequency array to count character occurrences, then traversing the string again to find the first character with a count of 1. The algorithm uses an array of size 256 to accommodate all ASCII characters. First, we count the frequency of each character, then we find the first character that appears exactly once. Algorithm Steps The solution follows these steps − Create an integer array of size 256 to store character frequencies ...

Read More

What are the different ways to find missing numbers in a sorted array without any inbuilt functions using C#?

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

Finding missing numbers in a sorted array is a common programming problem with multiple efficient solutions. This article explores three different approaches to identify missing numbers without using built-in functions in C#. Each method has its own advantages in terms of time and space complexity, making them suitable for different scenarios depending on your specific requirements. Using Sum Formula (Mathematical Approach) This method uses the mathematical formula n(n+1)/2 to calculate the expected sum of consecutive numbers, then subtracts the actual sum of array elements to find the missing number − using System; public class ...

Read More

How to find the missing number and the repeated number in a sorted array without using any inbuilt functions using C#?

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

Finding the missing number and the repeated number in a sorted array is a common programming problem. This article demonstrates how to solve this problem without using any built-in functions in C#. The approach uses a boolean array to track which numbers are present and an integer array to count occurrences. By traversing the original array and marking elements in auxiliary arrays, we can identify both the missing and repeated elements efficiently. Algorithm Overview The solution works in two main steps − Finding the missing number: Create a boolean array and mark elements as ...

Read More

How to find the minimum number of jumps required to reach the end of the array using C#?

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

The minimum number of jumps problem involves finding the least number of jumps required to reach the end of an array, where each element represents the maximum number of positions you can jump forward from that index. Given an array where each element represents the maximum jump length from that position, we need to find the minimum jumps to reach the last index. For example, in array {1, 3, 6, 3, 2, 3, 6, 8, 9, 5}, we can reach the end in 4 jumps. Jump Path Visualization 1 ...

Read More

How to rotate a matrix of size n*n to 90-degree k times using C#?

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

Rotating a matrix by 90 degrees is a common operation in programming. When we need to rotate a matrix k times, we can optimize by noting that 4 rotations return the matrix to its original state. Therefore, we only need to perform k % 4 rotations. The algorithm works by processing concentric squares within the matrix. For an n×n matrix, there are n/2 concentric squares. In each square, elements move in a cycle of 4 positions during a 90-degree clockwise rotation. 90° Clockwise Rotation Pattern Original ...

Read More

How to print a matrix of size n*n in spiral order using C#?

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

Printing a matrix in spiral order means traversing the matrix elements layer by layer from the outermost to the innermost layer. We start from the top-left corner and move in a clockwise direction: right, down, left, and up, then repeat for the inner layers. Algorithm Steps Step 1 − Print all elements of the top row from left to right Step 2 − Print all elements of the rightmost column from top to bottom Step 3 − Print all elements of the bottom row from right to left Step 4 − Print all elements of the leftmost ...

Read More

How to print number of islands in a given matrix using C#?

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

An island in a matrix is a group of connected cells containing '1' (representing land) that are surrounded by '0' (representing water). Two cells are considered connected if they are adjacent horizontally or vertically. This problem uses Depth-First Search (DFS) to traverse and mark all connected land cells as visited. The algorithm performs a linear scan of the 2D grid. When it finds a '1' that hasn't been visited, it triggers a DFS to explore the entire connected island and marks all cells in that island as visited. Each DFS call represents one complete island. Algorithm Steps ...

Read More

How to find all the permutation of the string by backtracking using C#?

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

String permutation using backtracking is a classic algorithm that generates all possible arrangements of characters in a string. The approach works by fixing one character at a time and recursively finding permutations of the remaining characters, then backtracking to explore other possibilities. The core idea is to swap characters systematically − fix the first position with each character, find permutations of the rest, then backtrack by undoing the swap to try the next possibility. Backtracking Process for "ABC" ABC ...

Read More

How to get all the combinations of the keypad value in a mobile by backtracking using C#?

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

The problem of generating all possible letter combinations from mobile keypad digits can be solved efficiently using backtracking. This approach explores all possible paths by making choices, exploring them recursively, and backtracking when a complete combination is formed. On a traditional mobile keypad, each digit from 2-9 corresponds to a set of letters. The goal is to find all possible combinations when given a sequence of digits. Mobile Keypad Mapping 2 ABC 3 DEF 4 ...

Read More
Showing 51–60 of 1,958 articles
« Prev 1 4 5 6 7 8 196 Next »
Advertisements