๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.57K subscribers
5.58K photos
3 videos
95 files
9.92K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
# include <bits/stdc++.h>
using namespace std;
#define ll long long
signed main(){
   
    string s; cin>>s;
    vector<ll>freq(26);
    for(auto it:s) freq[it-'a']++;
    bool f=0;
    for(ll i=0;i<26;i++)
    {
      if(freq[i]!=0) {cout<<char(i+'a'); f=1;}
      if(f) break;
    }
    if(!f) cout<<-1<<endl;
    return 0;
}
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include<bits/stdc++.h>
using namespace std;
#define int long long

int solve(int n, vector<int>& front, vector<int>& back, int frontend, int backend) {
    vector<vector<int>> dp(n + 1, vector<int>(frontend + 1, INT_MAX));
    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= frontend; j++) {
            if (dp[i][j] == INT_MAX) continue;
            if (j < frontend) {
                dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + front[i]);
            }
            int b = i - j;
            if (b < backend) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + back[i]);
            }
        }
    }

    return dp[n][frontend];
}

int32_t main() {
    int frontend, backend;
    cin >> frontend >> backend;
    int n = frontend + backend;
    vector<int> front(n), back(n);
   
    for (int i = 0; i < n; i++) {
        cin >> front[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> back[i];
    }

    int result = solve(n, front, back, frontend, backend);
    cout << result << endl;

    return 0;
}


Hiring Drive โœ