Create an empty new array of length 256, traverse through the entire string character by character and increment the value in the new array. At the end traverse the entire array and return the first character that has value 1.Example 1aabccd -→2 1 2 1 → Return the first character which is having count 1. That is b by subtracting with the ascii values.Example 2 Live Demousing System; namespace ConsoleApplication{ public class Arrays{ public char ReturnCharacterOfFirstUniqueCharachter(string s){ int index = -1; int[] arrayValues = new int[256]; ... Read More
Create an empty new array of length 256, traverse through the entire string character by character and increment the value in the new array. At the end traverse the entire array and return the first character that has value 1.Example 1aabccd -→2 1 2 1 → Return the first character which is having count 1. That is b.Example 2 Live Demousing System; namespace ConsoleApplication{ public class Arrays{ public int ReturnIndexOfFirstUniqueCharachter(string s){ int index = -1; int[] arrayValues = new int[256]; for (int i = 0; ... Read More
Create a method reverse Words that takes char array as an input and for each and every character until the empty space is not reached reverse the word. At the last step reverse the entire string from length 0 to n-1 length. In the first step the string “This is my book” will be turned into “koob ym si siht”. At the end of the second step the string words will be reversed to “book my is This”Time complexity − O(N)Example Live Demousing System; namespace ConsoleApplication{ public class Arrays{ static void reverse(char[] str, int start, int end){ ... Read More
The array is already sorted, we can keep two pointers ii and jj, where ii is the slow-runner while jj is the fast-runner. As long as nums[i] = nums[j]nums[i]=nums[j], we increment jj to skip the duplicate.When we encounter nums[j] != nums[i] the duplicate run has ended so we must copy its value to nums[i + 1]nums[i+1]. ii is then incremented and we repeat the same process again until jj reaches the end of array.Create an new array copy all the elements from the filtered array till the index and return the new array.Time complexity − O(N)Example Live Demousing System; namespace ConsoleApplication{ ... Read More
The array is already sorted, we can keep two pointers ii and jj, where ii is the slow-runner while jj is the fast-runner. As long as nums[i] = nums[j]nums[i]=nums[j], we increment jj to skip the duplicate.When we encounter nums[j] != nums[i] the duplicate run has ended so we must copy its value to nums[i + 1]nums[i+1]. ii is then incremented and we repeat the same process again until jj reaches the end of array.Time complexity − O(N)Example Live Demousing System; namespace ConsoleApplication{ public class Arrays{ public int RemoveDuplicatesFromSortedArrayAndReturnLength(int[] arr){ int index = 1; ... Read More
We need to take three-pointers, low, mid, high. We will use low and mid pointers at the start, and the high pointer will point at the end of the given array.If array [mid] =0, then swap array [mid] with array [low] and increment both pointers once.If array [mid] = 1, then no swapping is required. Increment mid pointer once.If array [mid] = 2, then we swap array [mid] with array [high] and decrement the high pointer once.Time complexity − O(N)Example Live Demousing System; namespace ConsoleApplication{ public class Arrays{ private void Swap(int[] arr, int pos1, int pos2){ ... Read More
Take two-pointers, low, high. We will use low pointers at the start, and the high pointer will point at the end of the given array.If array [low] =0, then no swapping requiredIf array [low] = 1, then swapping is required. Decrement high pointer once.Time complexity − O(N)Example Live Demousing System; namespace ConsoleApplication{ public class Arrays{ public void SwapZerosOnes(int[] arr){ int low = 0; int high = arr.Length - 1; while (low < high){ if (arr[low] == 1){ ... Read More
Given an array and number k, the problem states that we have to rotate the array k times.If the given number is 3 then the array must be rotated 3 times.Create a function reverse which takes the array, start and end as a parameter.In the 1st step call reverse method from 0 to array length.In the 2nd step call the reverse method from 0 to k-1.In the 3rd step call the reverse method from k+1 to array length.Example Live Demousing System; namespace ConsoleApplication{ public class Arrays{ public void ReverseArrayKTimes(int[] arr, int k){ Reverse(arr, ... Read More
What is a Denial-of-Service Attack?A Denial-of-Service (DoS) attack is an attack on a computer network that limits, restricts, or stops authorized users from accessing system resources.DoS attacks work by flooding the target with traffic or sending it data that causes it to crash. It deprives genuine users of the service or resources they expect to receive.DoS assaults frequently target high-profile corporations such as banks, commerce, media companies, and government and trade organizations' web servers.Even through DoS assaults seldom result in the theft or loss of critical information or other assets, they can take a lot of time and money to ... Read More
TCP stands for Transmission Control Protocol and IP stands for Internet Protocol. TCP/IP is a suite of protocols used for the communication of devices on a network. The network can be of any type: Internet or personal networks like the intranet, extranet, etc.The modern developments that we use on the Internet are only possible because of the TCP/IP suite. Although the name suggests only two protocols, it contains other protocols in it. Let us look at the functioning of this suite in detail.Working of TCP/IPIn simple terms, TCP takes care of how data is transferred in a network.It breaks down ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP