allcoding1
22.5K subscribers
2.19K photos
2 videos
77 files
909 links
Download Telegram
Python

INFOSYS EXAM ANS 10AM

ALL Slots are available

Telegram:- @allcoding1
                     @allcoding1

Discussion group:- @infosys_exam_Ans


Coding Ans:- https://instagram.com/allcoding1_official?igshid=OGQ2MjdiOTE=

Share with your friends
👍5
#include <bits/stdc++.h>
using namespace std;

int main() {
    string S;
    cin >> S;
    int n = S.length();
    int dp[n + 1];
    memset(dp, 0x3f, sizeof dp);
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        int digit = S[i] - '0';
        for (int j = max(0, i - 2); j < i; j++) {
            int sum = 0;
            for (int k = j; k <= i; k++) {
                sum += S[k] - '0';
            }
            if (sum % 3 == 0) {
                int cost = digit;
                for (int k = j; k <= i; k++) {
                    cost = min(cost, S[k] - '0');
//@allcoding1
                }
                dp[i + 1] = min(dp[i + 1], dp[j] + cost);
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}


C++


INFOSYS EXAM ANS 10AM

ALL Slots are available


Telegram:- @allcoding1
@allcoding1

discussion group:- @Infosys_exam_Ans

Coding Ans :- https://instagram.com/allcoding1_official?igshid=OGQ2MjdiOTE=

Share with your friends
👍20
Java 8

INFOSYS EXAM ANS 10AM

ALL Slots are available

Telegram:- @allcoding1
                     @allcoding1

Discussion group:- @infosys_exam_Ans


Coding Ans:- https://instagram.com/allcoding1_official?igshid=OGQ2MjdiOTE=

Share with your friends
👍9
def shortest_subarray(colors, C):
    n = len(colors)
    color_count = [0] * (C+1)
    left, right = 0, 0
    min_length = float('inf')
    count = 0
    while right < n:
        color_count[colors[right]] += 1
        if color_count[colors[right]] == 1:
            count += 1
        while count == C:
            min_length = min(min_length, right - left + 1)
            color_count[colors[left]] -= 1
            if color_count[colors[left]] == 0:
                count -= 1
            left += 1
        right += 1
    if min_length == float('inf'):
        return -1
    else:
        return min_length



Python3

INFOSYS EXAM ANS 10AM

ALL Slots are available

Telegram:- @allcoding1
                     @allcoding1

Discussion group:- @infosys_exam_Ans


Coding Ans:- https://instagram.com/allcoding1_official?igshid=OGQ2MjdiOTE=

Share with your friends
👍12
Python

INFOSYS EXAM ANS 10AM

ALL Slots are available

Telegram:- @allcoding1
                     @allcoding1

Discussion group:- @infosys_exam_Ans


Coding Ans:- https://instagram.com/allcoding1_official?igshid=OGQ2MjdiOTE=

Share with your friends
👍10
def next_stepping_number(N):
N = str(N)
for i in range(len(N) - 1):
if abs(int(N[i]) - int(N[i+1])) != 1:
return int(N[:i+1] + str(int(N[i]) + 1 if int(N[i]) < int(N[i+1]) else int(N[i]) - 1) + '9'*(len(N)-i-1))
return int(N) + 1

print(next_stepping_number(4)) # should return 5


INFOSYS EXAM ANS 10AM

ALL Slots are available


Telegram:- @allcoding1
@allcoding1

discussion group:- @Infosys_exam_Ans

Coding Ans :- https://instagram.com/allcoding1_official?igshid=OGQ2MjdiOTE=

Share with your friends
👍24😁2👏1
Java

INFOSYS EXAM ANS 10AM

ALL Slots are available

Telegram:- @allcoding1
                     @allcoding1

Discussion group:- @infosys_exam_Ans


Coding Ans:- https://instagram.com/allcoding1_official?igshid=OGQ2MjdiOTE=

Share with your friends
👍2
Java

INFOSYS EXAM ANS 10AM

ALL Slots are available


Telegram:- @allcoding1_official
                     @allcoding1_official

discussion group:- @Infosys_examAns

Coding Ans :- https://instagram.com/allcoding1_official?igshid=OGQ2MjdiOTE=

Share with your friends
👍6
Python

INFOSYS EXAM ANS 10AM

ALL Slots are available


Telegram:- @allcoding1_official
                     @allcoding1_official

discussion group:- @Infosys_examAns

Coding Ans :- https://instagram.com/allcoding1_official?igshid=OGQ2MjdiOTE=

Share with your friends
👍3
Python

Once check it out put

INFOSYS EXAM ANS 10AM

ALL Slots are available


Telegram:- @allcoding1
                     @allcoding1

discussion group:- @Infosys_exam_Ans

Coding Ans :- https://instagram.com/allcoding1_official?igshid=OGQ2MjdiOTE=

Share with your friends
👍145
def getLargestString(s, k):
    frequency_array = [0] * 26

    for i in range(len(s)):

        frequency_array[ord(s[i]) -
                        ord('a')] += 1
    ans = ""
    i = 25
    while i >= 0:
        if (frequency_array[i] > k):
            temp = k
            st = chr( i + ord('a'))
            
            while (temp > 0):
                ans += st
                temp -= 1
          
            frequency_array[i] -= k
            j = i - 1
            
            while (frequency_array[j] <= 0 and
                   j >= 0):
                j -= 1
            if (frequency_array[j] > 0 and
                j >= 0):
                str1 = chr(j + ord( 'a'))
                ans += str1
                frequency_array[j] -= 1
            
            else:
                break
        elif (frequency_array[i] > 0):
            temp = frequency_array[i]
            frequency_array[i] -= temp
            st = chr(i + ord('a'))
            while (temp > 0):
                ans += st
                temp -= 1
        else:
            i -= 1
            
    return ans          

if name == "main":
  
    S = input()
    k = 3
    print (getLargestString(S, k))


Python
Bob code

Telegram:- @allcoding1
👍23
Telegram:- @allcoding1
👍2