Majority Element Leetcode Solution

Problem Statement   We are given an array of integers. We need to return the integer which occurs more than ⌊N / 2⌋ time in the array where ⌊ ⌋ is the floor operator. This element is called the majority element. Note that the input array always contains a majority element. …

Read more

Online Algorithm for Checking Palindrome in a Stream

Problem Statement   In the “Online Algorithm for Checking Palindrome in a Stream” problem, we have given a stream of characters(charcaters are received one by one). Write a program that will print ‘yes’ every time if the received characters till now form a palindrome. Input Format   The first and only one …

Read more

Elements Appear more than N/K times in Array

Problem Statement   In the “Elements Appear more than N/K times in Array” problem we have given an integer array of size n. Find the elements which appear more than n/k times. Where k is the input value. Input Format   The first and only one line containing two integers N and …

Read more

Majority Element

Problem Statement   Given a sorted array, we need to find the majority element from the sorted array. Majority element: Number occurring more than half the size of the array. Here we have given a number x we have to check it is the majority_element or not. Example   Input 5 2 …

Read more