Skip to content
W3colleges

W3colleges

  • Home
  • Algorithms
    • Analysis of Algorithms
    • Searching
    • Sorting
    • Divide and Conquer
    • Greedy
    • Dynamic Programming
    • Backtracking
    • Branch and Bound
    • Graph And Algorithms
    • Pattern Searching
    • Mathematical
    • Geometric
  • Data Structures
    • Array
    • Queue
    • Stack
    • Linked List
    • Binary Tree
    • Graph
    • Hashing
    • String
  • C Programming
    • Basic
    • Pointers
    • Operators
    • Control Statement
    • Loops
    • Function
    • Array
    • Sorting
    • Advanced
  • C++ Programming
    • C++ Basics
    • Operators
    • Control Statements
    • Functions
    • Array
    • Constuctor and Destructor
    • Overloading & overriding
    • C++ Library
    • STL
    • Misc
      • Object Oriented
      • Inhertiance
      • Sorting
      • Advanced
  • Programs
    • C Programs
    • C++ Programs
  • CS Core
    • Operating Systems
    • DBMS
    • Computer Networks
  • Interviews
  • Contests
  • Python

Minimum Deletions to Make String Balanced

You are given a string s consisting only of characters ‘a’ and ‘b’​​​​. You can delete any number of characters in s to make s balanced. s is balanced if there is no pair of indices (i,j) such that i < j and s[i] = ‘b’ and s[j]= ‘a’. Return the minimum number of deletions needed to make… Read More »

Dynamic Programming Java Programs Queue Strings
Strings

Rearrange array to make it non-decreasing by swapping elements with equal GCD

Given an array (with all elements greater than 0), create a non-decreasing array by swapping 2 elements if their gcd(Greatest Common Factor) is equal to the minimum element of the array. You have to print “YES” if this is possible, and if not print “NO”. Examples: Input: a[] = {6,2,4,8,12} Output: YES Explaination: Swap a[1] and a[2] and… Read More »

Arrays C++ Programs Sorting
GCD

Calculate the maximum amount of money a person can make

Given three arrays start[], duration[], amount[] of length N. A person can make money of amount[i] working for the time period [start[i], start[i]+duration[i]] on task i. Maximum amount of money a person can make from the N tasks. Note: Person can work on only one task at a time. Example : Input : start[] = {15, 10, 30,… Read More »

Arrays C++ Programs Dynamic Programming Sorting
Binary Search Dynamic Programming

Find maximum time gap between cars in given interval

Given start and end time of all the cars in a given interval, find the maximum time gap in which no car travels. The start timings are given in sorted order. Examples: Input: start[] = { 1, 2, 6 } end[] = { 3, 5, 9 } Output: 1 Explanation: The first car travels from time unit 1… Read More »

Arrays C++ Programs Mathematical Sorting
Time

Find the MEX of given Array

Mex of an array is the smallest non-negative integer that does not appear in the array. Given an array of non-negative integers, find mex of its elements. Examples : Input : arr[] = {0, 3, 1, 2} Output : 4 All integers smaller than 4, i.e. 0, 1, 2 and 3 are present in the array. Hence mex… Read More »

Arrays C++ Programs Java Programs Python Programs Sorting

Minimum number of swaps required to sort an array

Given an array arr of size n, the task is to sort this array using minimum swaps. We are allowed to swap only adjacent elements. Examples: Input: arr[] = {1, 4, 3, 5, 2} Output: 4 Explaination: After 1st swap: arr[] = {1, 4, 3, 2, 5} After 2nd swap: arr[] = {1, 4, 2, 3, 5} After… Read More »

Arrays C Programs C++ Programs Java Programs Python Programs Sorting
Bubble Sort Sorting

Difference between Sum of odd and even indices elements in Array

Given an array with n elements, task is to calculate the difference between the sum of those elements occurring at odd indexes and those at even indexes. Note : For the above problem first we have to check for the bigger sum and from that subtract the smaller sum, either it is of even index or odd index.… Read More »

Arrays C++ Programs Mathematical
Sum

Maximizing Minimum Distance Between Magnets in Boxes

We have n boxes in which we have to place c magnets such that minimum distance between two magnet should be maximum. As we know any two magnet become aggressive when kept close to each other so we keep them as apart as possible. While keeping apart we calculate the minimum distance which we maximized. Input format: Line… Read More »

Arrays Dynamic Programming Java Programs

Crypt-Arithmetic problem in Artificial Intelligence

In Artificial Intelligence you will encounter this puzzle. Given below is a crypt-arithmetic problem solved. Example : SEND + MORE ——- = MONEY ——- CP + IS + FUN ——– = TRUE ——- All the different alphabets range from 0-9 and each and every alphabet should have a unique value. All the same letters have to be the… Read More »

Machine Learning Python Programs
Artificial Intelligence Puzzle

The Painter’s Partition Problem

You have to paint n boards of length {L1, L2, L3,…,Ln-1}. There are k painters available and each painter takes t time to paint 1 unit of board. You have to get this job done as soon as possible under the constraints that any painter will paint only contiguous sections of boards. 2 painters cannot share a board… Read More »

Divide and Conquer Dynamic Programming Java Programs Searching
Binary Search Partition

Posts navigation

  • ← Previous
  • 1
  • …
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • …
  • 40
  • Next →

Recent Posts

  • Four Pillars of Object-Oriented Programming (OOPS)
  • Minimize Difference Between Sum of Squares in Array Permutation
  • Find the occurrence of every element among all possible subarrays of the array
  • Compare Two Lists
  • Convert Number n to 1 in Minimum Steps
  • Generate All Distinct Subsequences of Length m from Numbers 1 to n with Repetitions
  • Default Parameters in Python Functions
  • Check if given string contains Even 1’s and Odd 0’s
  • Check if a Clique Can Be Divided into Two Equal Halves
  • Python Methods to Remove Spaces from Dictionary Values

Categories

  • Algorithms
  • Analysis
  • Arrays
  • Backtracking
  • Bit Magic
  • Blog
  • C
  • C Programs
  • C++
  • C++ Programs
  • Combinatorial
  • Compiler Design
  • Computer Networks
  • Computer Organization and Architecture
  • Data Structures
  • DBMS
  • Difference Between
  • Digital Logic
  • Divide and Conquer
  • Dynamic Programming
  • GATE CS
  • Git
  • Graph
  • Greedy
  • Hash
  • Heap
  • HTML
  • Internship
  • Interviews
  • Java
  • Java Programs
  • JavaScript
  • Linked List
  • Machine Learning
  • Mathematical
  • Matrix
  • Misc
  • MongoDB
  • MySQL
  • NoSQL
  • Operating Systems
  • Pattern Searching
  • Python
  • Python Programs
  • Queue
  • Recursion
  • Searching
  • Sorting
  • SQL
  • Stack
  • Strings
  • Tree
  • Web Technology

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
About Us | Contact | Feedback | Privacy Policy | Copyright
Sitemap