Let’s suppose we have given an array of unsorted integers. The task is to find the positive missing number which is not present in the given array in the range [0 to n]. For example, Input-1 −N = 9 arr = [0, 2, 5, 9, 1, 7, 4, 3, 6]Output −8Explanation − In the given unsorted array, ‘8’ is the only positive integer that is missing, thus the output is ‘8’.Input-2 −N = 1 arr = [0]Output −1Explanation − In the given array, ‘1’ is the only one positive integer which is missing, thus the output is ‘1’.Approach to solve ... Read More
A linked list is a linear data structure that has multiple nodes that are connected with each other. Each node consists of two fields Data Field and address of the next node. Let us assume we have given a singly linked list the task is to find the kth node from the end in a given singly linked list. For example, Input −1→2→3→4→7→8→9 K= 4Output −Node from the 4th Position is − 4Explanation − Since in the given singly linked list ‘4th’ node from the end is ‘4’, we will return the output as ‘4’.Approach to solve this problemInitially, we ... Read More
Given a string ‘s’, the task is to find the first unique character which is not repeating in the given string of characters and return its index as output. If there are no such characters present in the given string, we will return ‘-1’ as output. For example, Input-1 −s = “tutorialspoint”Output −1Explanation − In the given string “tutorialspoint”, the first unique character which is not repeating is ‘u’ which is having the index ‘1’. Thus we will return ‘1’ as output.Input-2 −s = “aaasttarrs”Output −-1Explanation − In the given string “aaasttarrs’, there are no unique characters. So, we will ... Read More
Let's suppose we have a string ‘str’ which consists of some character in it. The task is to check whether the given string has all its characters capitalized or not and return True or False respectively. For example, Input-1 −str = “INDIA”Output −TrueExplanation − Since all the character of the input string is capital, we will return true in this case.Input-2 −str = “Programmer”Output −FalseExplanation − Since all the characters of the input string are not in the capital except the first letter, we will return false in this case.The approach used to solve this problemIn the given string, we ... Read More
A Linked List is a linear Data Structure that contains nodes and each node has two fields; one is the value or data to be inserted and the other field stores the address of the next node.Our task here is to delete a node from the end of a Linked List. The last node is known as the tail node. If there is no node in the Linked List, then return NULL.For example −Input 1 − 1 → 2 → 3 → 4 → 5Output − 1 → 2 → 3 → 4 →Explanation − In the given singly linked ... Read More
Let's suppose we have given a number N. the task is to find the total number of digits present in the number. For example, Input-1 −N = 891452Output −6Explanation − Since the given number 891452 contains 6 digits, we will return ‘6’ in this case.Input-2 −N = 0074515Output −5Explanation − Since the given number 0074515 contains 5 digits, we will print the output as 5.The approach used to solve this problemWe can solve this problem in the following way, Take input ‘n’ as the number.A function countDigits(n) takes input ‘n’ and returns the count of the digit as output.Iterate over all ... Read More
A good meal contains exactly two different food items with a sum of deliciousness equal to a power of two. You can pick any two different foods to make a good meal.Let us suppose we have given an array of integers arr where arr[i] is the deliciousness of the ith item of food, return the number of different good meals you can make from this list.For example, Input-1 −arr[ ] = {1, 3, 5, 7, 9}Output −4Explanation − The good meals are (1, 3), (1, 7), (3, 5) and, (7, 9). Their respective sums are 4, 8, 8, and 16, ... Read More
Given two strings ‘a’ and string ‘b’, we have to check if they are anagrams of each other or not and return True/False. For example, Input-1 −String a= “india” String b= “nidia”Output −TrueExplanation − Since the given string ‘b’ contains all the characters in the string ‘a’ thus we will return True.Input-2 −String a= “hackathon” String b= “achcthoon”Output −FalseExplanation − Since the given string ‘b’ doesn’t have all the characters as string ‘a’ have thus we will return False.The approach used to solve this problemIn the given strings ‘a’ and ‘b’, we will check if they are of the same ... Read More
Suppose we’ve two strings ‘a’ and ‘b’, the task is to find whether we can obtain string ‘b’ by rotating string ‘a’ exactly by 2 places in an anticlockwise or clockwise direction. For example, Input-1 −a = google b = legoogOutput −TrueExplanation − String ‘google’ can be rotated in an anticlockwise direction by two places, which results in the string ‘legoog’. Thus, we return True.Input-2 −a = tuorialst b = tutorialsOutput −FalseExplanation − String ‘tuorialst’ cannot be rotated by two places in any direction to get another string ‘tutorials’. Thus, we return False.The approach used to solve this problemFor the ... Read More
A linked list is a linear data structure that has multiple nodes that are connected with each other. Each node consists of two fields – Data Field and the address of the next node.Let us assume we have a singly linked list and we need to delete the first node from this linked list. For example, Input 1 − 4 → 3 → 2 → 1Output − 3 → 2 → 1 →Explanation − ‘4’ is the first node in the given singly linked list. After deleting the first node, the linked list will be 3→2→1.Input 2 − 1 → ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP