Need help with some problems!

Revision en1, by cp.exe, 2024-10-24 12:21:04

Problem1 :

Given a string S, find for all substrings of S the minimum cost of operations needed to make each of its substring a palindrome. In one operation you can,

1) Either rearrange the substring with cost 0 or, 2) Replace a character with cost 1

I came up with a O(26 * N * N) solution, but the constraints N <= 1e5. How to solve it?

Problem2:

Given an array weight[] and profit[] (similar to Knapsack Problem) you are also given the size of the knapsack W. you need to find a subset whose bitwise OR is <= W and the profits are maximum. Constraints : N <= 1e5, weight[i] <= 1e9, W <= 1e9, profit[] <= 1e9.

Thanks for the help in advance!!!

Tags dp, greedy, oa, bitwise, strings, optimization

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English cp.exe 2024-10-24 12:21:04 697 Initial revision (published)