Neetika Khandelwal

Neetika Khandelwal

22 Articles Published

Articles by Neetika Khandelwal

22 articles

Replace two Substrings (of a String) with Each Other

Neetika Khandelwal
Neetika Khandelwal
Updated on 27-Mar-2026 262 Views

Replacing two substrings with each other requires careful handling of overlapping matches. Python provides several approaches to solve this problem efficiently using string methods and regular expressions. Problem Understanding Given a string S and two substrings A and B, we need to replace every occurrence of A with B and every occurrence of B with A. When both substrings are found at the same position, we prioritize the leftmost match. Example S = "aab" A = "aa" B = "bb" # Expected output: "bbb" print(f"Input: S='{S}', A='{A}', B='{B}'") Input: S='aab', A='aa', ...

Read More

Minimum number of given Operations Required to Convert a String to Another String

Neetika Khandelwal
Neetika Khandelwal
Updated on 27-Mar-2026 2K+ Views

You are given two strings A and B, the task is to convert string A to string B using only one operation: taking any character from A and inserting it at the front. We need to find the minimum number of such operations required for transformation. Problem Understanding The key insight is that we can only move characters from their current position to the front of the string. This means we need to work backwards and check which characters are already in the correct relative order. Example 1 For strings A = "ABD" and B = ...

Read More

Find the Order of Execution of given N Processes in Round Robin Scheduling

Neetika Khandelwal
Neetika Khandelwal
Updated on 27-Mar-2026 781 Views

In this article, you will learn how to find the order of execution for given N processes using the Round Robin Scheduling algorithm. Round Robin is a preemptive CPU scheduling algorithm that allocates CPU time fairly among processes using fixed time slices. What is Round Robin Scheduling? Round Robin Scheduling is a preemptive scheduling algorithm where each process receives a fixed time slice (quantum) to execute. The CPU scheduler allocates time to processes in a circular order. Once a process uses its time slice, it's preempted and moved to the end of the ready queue. The time ...

Read More

Java ArrayList to print all possible words from phone digits

Neetika Khandelwal
Neetika Khandelwal
Updated on 24-Oct-2024 562 Views

In this article, we will learn to generate all possible words from a string of phone digits using Java. Each digit on a mobile keypad corresponds to a set of letters, and our task is to find every possible combination of letters that can be formed by pressing those digits. For instance, if the input is "23, " the output would include combinations like "ad, " "ae, " "af, " and so on. We will implement a recursive approach to achieve this, allowing us to systematically generate and print all possible words corresponding to the given digits. Problem Statement Write ...

Read More

Minimum Number of Operations to move all Uppercase Characters before all Lower Case Characters

Neetika Khandelwal
Neetika Khandelwal
Updated on 22-Aug-2023 486 Views

You are given a string 'str' that contains both uppercase and lowercase letters. Any lowercase character can be changed to an uppercase character and vice versa in a single action. The goal is to print the least possible instances of this process that are necessary to produce a string containing at least one lowercase character, followed by at least one uppercase character. Input Output Scenarios First possible solution: the first 4 characters can be converted to uppercase characters i.e. “TUTORial” with 4 operations. Input str = “tutoRial” Output 1 Second possible solution: the third character ...

Read More

Generate a String Consisting of Characters ‘a’ and ‘b’ that Satisfy the given Conditions

Neetika Khandelwal
Neetika Khandelwal
Updated on 22-Aug-2023 746 Views

The task is to generate a string that consists of characters ‘a’ and ‘b’ which satisfies the condition mentioned below: str must have a length of A+B. The character 'a' must appear A times and the character 'b' must appear B times within the string. The sub−strings "aaa" and "bbb" should not appear in str. After generating the string, it should be printed. One possible solution is to first generate a string with all 'a's and 'b's, with 'a' occurring A times and 'b' occurring B times. Then, we can shuffle the string randomly until we find a ...

Read More

First Come, First Serve ñ CPU Scheduling | (Non-preemptive)

Neetika Khandelwal
Neetika Khandelwal
Updated on 22-Aug-2023 1K+ Views

FCFS CPU Scheduling (First Come, First Serve) is a fundamental CPU scheduling mechanism that executes programs in the order they are added to the ready queue. In other words, the first process to come will be carried out first, and so on. Since it uses a non−preemptive scheduling technique, a process that has been allocated to the CPU will keep running until it is finished or enters a waiting state. Scenario 1 Let's take a look at an example to understand FCFS CPU scheduling in more detail. Suppose we have three processes with the following arrival times and burst times: ...

Read More

Finding Optimal Page Size

Neetika Khandelwal
Neetika Khandelwal
Updated on 22-Aug-2023 681 Views

Operating system has a concept known as the optimal page size that is affected by a number of variables, such as the system architecture, the amount of physical memory at hand, and the workload of the running applications. Steps/ Approach The following steps can be used to find the ideal page size: Step 1: Establish the system's design:Different CPU designs support varied page sizes. For instance, x86 CPUs typically offer 4KB page sizes, whereas ARM CPUs support 4KB, 16KB, or 64KB page sizes. Step 2: Calculate the physical memory capacity:The ideal page size depends on the physical memory capacity. Larger ...

Read More

Find time taken to Execute the Tasks in A Based on the Order of Execution in B

Neetika Khandelwal
Neetika Khandelwal
Updated on 22-Aug-2023 241 Views

The goal is to determine the minimum time required to complete the tasks in queue A based on the order of execution in queue B, given two queues A and B, each of size N, where: Pop this task and run it if the task identified at the head of queue B is also at the head of queue A. Pop the current task from queue A and push it at the end if the task discovered at the front of queue B is not also found at the front of queue A. One unit of time is ...

Read More

Find the Time Taken Finish Processing of given Processes

Neetika Khandelwal
Neetika Khandelwal
Updated on 22-Aug-2023 240 Views

Given are N processes and two N−sized arrays, arr1[] and arr2[]. A process's time in the critical section is recorded in arr1[], and it’s time to finish processing after leaving the critical part is recorded in arr2. The goal is to determine how long it will take for each process to finish processing (both inside and outside of the critical section) in any given order. Input Output Scenarios Assume we have 3 arrays as shown below Input N = 3, arr1[] = {1, 4, 3}, arr2[] = {2, 3, 1} Output 9 The first process, at ...

Read More
Showing 1–10 of 22 articles
« Prev 1 2 3 Next »
Advertisements