[LeetCode] Sum of Total Strength of Wizards

2281. Sum of Total Strength of Wizards

As the ruler of a kingdom, you have an army of wizards at your command.

You are given a 0-indexed integer array strength, where strength[i] denotes the strength of the ith wizard. For a contiguous group of wizards (i.e. the wizards’ strengths form a subarray of strength), the total strength is defined as the product of the following two values:

  • The strength of the weakest wizard in the group.
  • The total of all the individual strengths of the wizards in the group.

Return the sum of the total strengths of all contiguous groups of wizards. Since the answer may be very large, return it modulo 109 + 7.

A subarray is a contiguous non-empty sequence of elements within an array.

Read more
[Geeks for Geeks] Majority Element

Majority Element

Given an array A of N elements. Find the majority element in the array. A majority element in an array A of size N is an element that appears more than N/2 times in the array.

Read more
[Geeks for Geeks] Stock buy and sell

Stock buy and sell

The cost of stock on each day is given in an array A[] of size N. Find all the days on which you buy and sell the stock so that in between those days your profit is maximum.

Read more
[Geeks for Geeks] Smallest Positive Integer that can not be represented as Sum

Smallest Positive Integer that can not be represented as Sum

Given an array of size N, find the smallest positive integer value that cannot be represented as sum of some elements from the array.

Read more
[Geeks for Geeks] Convert array into Zig-Zag fashion

Convert array into Zig-Zag fashion

Given an array Arr (distinct elements) of size N. Rearrange the elements of array in zig-zag fashion. The converted array should be in form a < b > c < d > e < f. The relative order of elements is same in the output i.e you have to iterate on the original array only.

Read more
[Geeks for Geeks] Count triplets with sum smaller than X

Count triplets with sum smaller than X

Given an array arr[] of distinct integers of size N and a value sum, the task is to find the count of triplets (i, j, k), having (i<j<k) with the sum of (arr[i] + arr[j] + arr[k]) smaller than the given value sum.

Read more
[Geeks for Geeks] Find all possible palindromic partitions of a String

Find all possible palindromic partitions of a String

Given a String S, Find all possible Palindromic partitions of the given String.

Read more
[Geeks for Geeks] Special array reversal

Special array reversal

Given a string S, containing special characters and all the alphabets, reverse the string without

affecting the positions of the special characters.

Read more
[Geeks for Geeks] Count Total Setbits

Count Total Setbits

You are given a number N. Find the total number of setbits in the numbers from 1 to N.

Read more
[Geeks for Geeks] Binary representation

Binary representation

Write a program to print Binary representation of a given number N.

Read more