#### Category : dsa

QSN. Given an unsorted linked list of N nodes. The task is to remove duplicate elements from this unsorted Linked List. When a value appears in multiple nodes, the node which appeared first should be kept, all others duplicates are to be removed. I tried to write this code on my own but showing error ..

The problem is: A string s is good if it is possible to rearrange the characters of s such that the new string formed contains "prep" as substring. So the string "proper" is good but "poor" is not. Given an integer n, find the number of only lowercase English characters. As this number might be ..

class Solution { public: ListNode* reverseList(ListNode* head) { ListNode* temp=new ListNode(); while(head!=nullptr){ temp= new ListNode(head->val ,temp); head= head->next; } return temp; } }; When I run this code it reverses the linked list but it also add dead (0) node at the end so what should I do to avoid it ?? input [1,2,3,4,5] My ..

In the following code: #include<iostream> using namespace std; int main() { int A[5] = {10,20,30,40,50}; // Let us try to print A[5] which does NOT exist but still cout <<"First A[5] = "<< A[5] << endl<<endl; //Now let us print A[5] inside the for loop for(int i=0; i<=5; i++) { cout<<"Second A["<<i<<"]"<<" = "<<A[i]<<endl; } ..

enter image description here we are given a array with the index value in which ,we need to check if that index value in the array(given tree) is on correct position or not if not then place the ele on correct position and this process is called heapify. //min-heapify #include<bits/stdc++.h> using namespace std; class minHeap{ ..

Magic number standard input/output: 2s/128000 kB A magic number is a natural number that contains both the digits 7 and 9 in it. For eg:- 79, 879, 53729 etc. Given a number N, your task is to find the closest Magic number from the given number N. Note:- If more than one answer exists return ..

I was solving this question: Given arrival and departure times of all trains that reach a railway station. Find the minimum number of platforms required for the railway station so that no train is kept waiting. Consider that all the trains arrive on the same day and leave on the same day. Arrival and departure ..