๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.61K photos
3 videos
95 files
10.6K 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
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
public static void main (String[] args) throws java.lang.Exception
  {
        int tes=1;
        StringBuilder sb=new StringBuilder();
      lable:for(int fuck=1;fuck<=tes;fuck++)
      {
            int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt(),i,j,l,ans=-1;
            int a[][]=new int[n][m];
            for(i=0;i<n;i++)
            for(j=0;j<m;j++)
            a[i][j]=sc.nextInt();
            for(i=0;i<n;i++){
                int b[][]=new int[n][m];
                for(j=0;j<i;j++)
                for(l=0;l<m;l++) b[j][l]=a[j][l];
                for(j=i;j<Math.min(n,i+k);j++){
                    for(l=0;l<m;l++){
                    if(a[j][l]==2) b[j][l]=0;
                    else b[j][l]=a[j][l];
                    }
                }
                for(j=i+k;j<n;j++)
                for(l=0;l<m;l++) b[j][l]=a[j][l];
                for(j=0;j<m;j++){
                    int tmp=bfs(b,j,n,m);
                    ans=Math.max(ans,tmp);
                }
            }
            System.out.println(ans);
        }
        System.out.println(sb);
    }
    public static int bfs(int b[][],int j,int n,int m){
        int dis[][]=new int[3][2];
        dis[0][0]=1; dis[0][1]=-1;
        dis[1][0]=1; dis[1][1]=0;
        dis[2][0]=1; dis[2][1]=1;
        Queue<Pair> que=new LinkedList<>();
        int dp[][]=new int[n][m];
        for(int it[]:dp) Arrays.fill(it,-1);
        if(b[0][j]==2) return -1;
        dp[0][j]=b[0][j];
        que.add(new Pair(0,j));
        while(que.size()>0){
            int size=que.size();
            for(int i=0;i<size;i++){
                Pair top=que.poll();
                for(int it[]:dis){
                    int x=top.f+it[0];
                    int y=top.s+it[1];
                    if(x>=0 && x<n && y>=0 && y<m && dp[top.f][top.s]+((b[x][y]==2)?-1:b[x][y])>=0){
                        dp[x][y]=Math.max(dp[x][y],dp[top.f][top.s]+((b[x][y]==2)?-1:b[x][y]));
                        que.add(new Pair(x,y));
                    }
                }
            }
        }
        int max=-1;
        for(int i=0;i<m;i++) max=Math.max(max,dp[n-1][i]);
        return max;
    }

Pseudorandom Number generatorโœ…
#include <iostream>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;
int getMinMoves(string s) {
    int n = s.length();
    int moves = 0;
    for (int i = 1; i < n; ++i) {
        if (s[i] != s[i - 1]) {
            int costPrev = abs(s[i] - s[i - 1]);
            int costNext = (i < n - 1) ? abs(s[i] - s[i + 1]) : INT_MAX;
            if (costPrev <= costNext) {
                s[i] = s[i - 1];
                moves += costPrev;
            } else {
                s[i + 1] = s[i];
                moves += costNext;
            }
        }
    }

    return moves;
}

String modification โœ…
๐Ÿ‘1
One advice to all the freshers out there!! For a single job openings 1000s of candidates are applying and getting your resume shortlisted for further process are quite tough.

Instead, check with your friends and collegemate, when they get placed they will received an offer letter from HR, ask them to share the HR mail id and try to reach out directly.

In this way chances of getting replied back will be more.
๐Ÿ‘6
#include <bits/stdc++.h>
  using namespace std;

  int main() {
    int mod = 1000000007;
    string s;
    cin>>s;
    long long n = s.size();
    long long i=0;
    long long ans = 1;
    for(i=0;i<n;i++){
      long long c = 1;
      while(i<n-1 && s[i]==s[i+1]){
        c++;
        i++;
      }
      ans = (ans*c)%mod;
     
    }
    cout<<ans%mod;
    return 0;

  }

Alex Keyboard โœ…
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> candies(N);
    for (int i = 0; i < N; ++i) {
        cin >> candies[i];
    }
    int min_value = candies[0];
    int max_tastiness_index = -1;
    for (int i = 1; i < N; ++i) {
        int current_difference = candies[i] - min_value;
        if (current_difference > max_tastiness_index) {
            max_tastiness_index = current_difference;
        }
        if (candies[i] < min_value) {
            min_value = candies[i];
        }
    }
    cout << max_tastiness_index << endl;
    return 0;
}

Tastiness index โœ…
๐Ÿ‘2
#include<bits/stdc++.h>
using namespace std;

int maxi = 0;

int F(int col , vector<vector<int>> &a , vector<int> &dp){
    if(col == a[0].size()){
        return maxi = max(maxi , (int) dp.size());
    }
    for(int row = 0 ; row < a.size() ; row++){
        if(dp.size() == 0 || dp.back() < a[row][col]){
            dp.push_back(a[row][col]);
            F(col + 1 , a , dp);
            dp.pop_back();
        }
        else{
            int id = lower_bound(dp.begin() , dp.end() , a[row][col]) - dp.begin();
            int old = dp[id];
            dp[id] = a[row][col];
            F(col + 1 , a , dp);
            dp[id] = old;
        }
    }
}

int longestSequence(vector<vector<int>> &matrix){
    maxi = 0;
    vector<int> dp;
    F(0 , matrix , dp);
    return maxi;
}

DE Shaw โœ