Infosys 22nd January 2023 Both Slots 10 AM and 3 PM Live Coding Question and Solution | Refresh Every 5 Seconds for New Updates | SP | DSE Hiring | Page Vanish After the Exam



Infosys Urgent Off Campus Drive 20223 As Specialist Programmer and Digital Specialist Engineer Role
Infosys Urgent Off Campus Drive 20223 As Specialist Programmer and Digital Specialist Engineer Role

Join Our WhatsApp Group

Infosys 22nd January 2023 Both Slots 10 AM and 3 PM Live Coding Question and Answers | Refresh Every 5 Seconds for New Updates | SP | DSE Hiring | Page Vanish After the Exam:


Infosys Officially Announced Hiring Freshers Engineering Graduates as Below Mentioned positions. Infosys Hiring for Specialist Programmer and Digital Specialist Engineer Role in PAN, India, India Software, and Services For the full time. Infosys company is going to recruit candidates for graduates off-campus. The candidates who have completed B.E/ B.Tech/ M.E/ M.Tech/ MCA/ M.Scin Any Specialization  Graduates Engineering Graduates degree in any Streams/Branch Pass out in the Year 2022/ 2021/ 2020 Batch Eligible Only. batches are Eligible to apply

In this article, you can easily find the Infosys address, date of interview, eligibility details, interview syllabus, selection process, application link, and application procedure details explanation is given below.

In this article, you will get to know this drive, and also you can prefer a video that I created for your better understanding firstly understand the few points which I discussed in this video before applying.

For more such Latest new off-campus drives and for many years, internships, and free courses are updated on our website.

Infosys 2022 Recruitment Drive For Freshers – Any Batch:

Company NameInfosys.

ExperienceFreshers/Any

Job TitleSpecialist Programmer and Digital Specialist Engineer

Country/Region: IN

Qualification: B.E/ B.Tech/ M.E/ M.Tech/ MCA/ M.Sc

Branch: Any Branch or Stream Eligible.

Job Location: PAN, India.

Year of Passing: 2022/ 2021/ 2020 Batch Only.

Stipend Details: INR ₹ 6,25,000 - 9,50,000 L.P.A.

Full-Time/Part-Time: Full-Time Employee

Application Deadline: Soon.

Job Posted: December 22, 2022.

Company Profile: Summary

Infosys Limited is an Indian multinational information technology company that provides business consulting, information technology and outsourcing services. The company was founded in Pune and is headquartered in Bangalore. Wikipedia

Get The Future You Want | www.Infosys.com

Infosys 22nd January 2023 Both Slots 3 PM Live Coding Question and Solution Refresh Every 5 Seconds for New Question or else use search Option 'Control F':


  • # Python 3 program to find subsequence
  • # of size k with maximum possible GCD.
  • import math

  • # function to find GCD of sub sequence
  • # of size k with max GCD in the array
  • def findMaxGCD(arr, n, k):

  •     # Computing highest element
  •     high = max(arr)

  •     # Array to store the count of
  •     # divisors i.e. Potential GCDs
  •     divisors = [0] * (high + 1)

  •     # Iterating over every element
  •     for i in range(n) :

  •         # Calculating all the divisors
  •         for j in range(1, int(math.sqrt(arr[i])) + 1):

  •             # Divisor found
  •             if (arr[i] % j == 0) :

  •                 # Incrementing count for divisor
  •                 divisors[j] += 1

  •                 # Element/divisor is also a divisor
  •                 # Checking if both divisors are
  •                 # not same
  •                 if (j != arr[i] // j):
  •                     divisors[arr[i] // j] += 1

  •     # Checking the highest potential GCD
  •     for i in range(high, 0, -1):

  •         # If this divisor can divide at least k
  •         # numbers, it is a GCD of at least one
  •         # sub sequence of size k
  •         if (divisors[i] >= k):
  •             return i

  • # Driver code
  • if name == "main":

  •     # Array in which sub sequence with size
  •     # k with max GCD is to be found
  •     arr = [ 1, 2, 4, 8, 8, 12 ]
  •     k = 3

  •     n = len(arr)
  •     print(findMaxGCD(arr, n, k))

  • # This code is contributed by ita_c

______

                             
3PM Slots Ans
____________________________-

3PM Slots Ans

___________________

3PM Slots Ans

____________________

  • public static int beautyNumber(int N, long C, int[] A) {
  •         int count = 0;
  •         HashMap<String, Integer> subArrays = new HashMap<>();
  •         for (int i = 0; i < N; i++) {
  •             int left = 0, right = 0, sum = 0;
  •             while (sum <= A[i]) {
  •                 sum += U[right];
  •                 if (sum == A[i]) {
  •                     String subArray = Arrays.toString(Arrays.copyOfRange(U, left, right + 1));
  •                     if (!subArrays.containsKey(subArray)) {
  •                         count++;
  •                         subArrays.put(subArray, 1);
  •                     }
  •                 }
  •                 right++;
  •             }
  •         }
  •         return count;
  •     }
3PM Slots Ans

______________________


  • #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');
  •                 }
  •                 dp[i + 1] = min(dp[i + 1], dp[j] + cost);
  •             }
  •         }
  •     }
  •     cout << dp[n] << endl;
  •     return 0;
  • }


  • C++


  • INFOSYS EXAM ANS 3PM Slots Ans

  • ALL Slots are available 
______________________________


3PM Slots Ans

_________________________


  • 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

  • Python

  • INFOSYS EXAM ANS 3PM Slots Ans
_________________________



3PM Slots Ans

__________________________

  • 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 3PM Slots Ans

  • ALL Slots are available 
______________________________



3PM Slots Ans

_____________________-


3PM Slots Ans

___________________________



3PM Slots Ans

______________________


3PM Slots Ans

_______________________


_____________________


3PM Slots Ans

_____________________________


  • 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

  • 3PM Slots Ans


  • Python3 
___________________________

  • Next Stepping Number code
  • https://telegram.me/PLACEMENTLELO

  • 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 
  • 3PM Slots Ans

  • Python3
___________________

  • #include<bits/stdc++.h>
  • using namespace std;

  • const int mod = 1'000'000'007;

  • const int MAX_CHAR = 26;

  • long long fac[100002];

  • void factorial(int size)
  • {
  •     fac[0]=1;
  •     fac[1]=1;
  •     for (int j = 2; j <=size; j++) {
  •          fac[j]=((fac[j-1]%mod)*j)%mod;
  •     }
  • }

  • int countDistinctPermutations(string str)
  • {
  •     int length = str.length();
  •  
  •     int freq[MAX_CHAR]={0};
  •     // memset(freq, 0, sizeof(freq));
  •     for (int i = 0; i < length; i++)
_____________3PM Slots Ans
______________________


  • #include<stdio.h>
  • Int main(){
  • Int n,x;
  • Scanf(”%d",&n);
  • int n=x;
  • For (int i=0;i<=n-1;i++){
  • scanf(''%d'',&a[i]);
  • x=2*x-a[i];
  • }
  • Printf("%d",x);

  • }

  • C language


  • INFOSYS EXAM ANS 3PM Slots Ans
___________________________

  • import random

  • def A(S):
  •     return S[::-1]

  • def B(S):
  •     S = list(S)
  •     random.shuffle(S)
  •     return "".join(S)

  • def C(S, T):
  •     S = list(S)
  •     T = list(T)
  •     result = []
  •     while S and T:
  •         if random.random() < 0.5:
  •             result.append(S.pop(0))
  •         else:
  •             result.append(T.pop(0))
  •     result += S + T
  •     return "".join(result)

  • def Bob(M, N):
  •     N = "".join(sorted(list(N)))
  •     A_N = A(N)
  •     B_N = B(N)
  •     C_N = C(A_N, B_N)
  •     return C_N

  • print(Bob("C(A(N), B(N))", "abab")) # output may vary but it will be one of the lexicographically smallest possible string
___________________3PM Slots Ans
___________


___________3PM Slots Ans
____________-

  • import java.util.ArrayList;

  • public class Subsequence {
  •     static ArrayList<ArrayList<Integer>> findSubsequences(int[] A, int N, int K) {
  •         ArrayList<ArrayList<Integer>> ans = new ArrayList<>();
  •         for (int i = 0; i < (1<<N); i++) {
  •             ArrayList<Integer> temp = new ArrayList<>();
  •             int sum = 0;
  •             for (int j = 0; j < N; j++) {
  •                 if ((i & (1<<j)) != 0) {
  •                     sum += A[j];
  •                     temp.add(A[j]);
  •                 }
  •             }
  •             if (sum < K) {
  •                 ans.add(temp);
  •             }
  •         }
  •         return ans;
  •     }

  •     public static void main(String[] args) {
  •         int[] A = {1, 2, 3, 4, 5, 6, 7};
  •         int N = A.length;
  •         int K = 10;
  •         ArrayList<ArrayList<Integer>> ans = findSubsequences(A, N, K);
  •         System.out.println(ans);
  •     }
  • }3PM Slots Ans
_____________________________

 


3PM Slots Ans

_______________________


3PM Slots Ans

________________________

3PM Slots Ans

___________________________




3PM Slots Ans

___________________________

  • Python
  • Bob code

  • 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
  • 3PM Slots Ans

______________

3PM Slots Ans

____________



3PM Slots Ans


____________________


  • def count_special_strings(t, strings):
  •     for s in strings:
  •         count = 0
  •         special_string_count = 0
  •         for c in s:
  •             if c == 'b' or c == '%':
  •                 count += 1
  •         for i in range(1, len(s)):
  •             if s[i:].count('b') + s[i:].count('%') == count:
  •                 special_string_count += 1
  •         print(special_string_count)
_______3PM Slots Ans
__________


  • // N flowers on a Recatangular 
  • int ans = 100000000;
  • void solve(vector<int> a, int n, int k, int index, int sum,
  •            int maxsum)
  • {
  •     if (k == 1)
  •     {
  •         maxsum = max(maxsum, sum);
  •         sum = 0;
  •         for (int i = index; i < n; i++)
  •         {
  •             sum += a[i];
  •         }
  •         maxsum = max(maxsum, sum);
  •         ans = min(ans, maxsum);
  •         return;
  •     }
  •     sum = 0;
  •     for (int i = index; i < n; i++)
  •     {
  •         sum += a[i];
  •         maxsum = max(maxsum, sum);
  •         solve(a, n, k - 1, i + 1, sum, maxsum);
  •     }
  • }
  • int GetMaxBeauty(int N, int K, vector<int> A)
  • {

  •     solve(A, N, K, 0, 0, 0);
  •     return ans;
  • }

  • // N flowers on a Recatangular 3PM Slots Ans

___________

  • //Given Array A having N integers and divisor K


  • int morethanNbyK(vector<int> arr, int n, int k)
  • {
  •     int x = n / k;
  •     int ans = 0;
  •     unordered_map<int, int> freq;
  •     for (auto i : arr)
  •         freq[i]++;
  •     for (auto i : freq)
  •     {
  •         if (i.second > x)
  •         {
  •             ans += i.first;
  •         }
  •     }
  •     return ans;
  • }
________3PM Slots Ans
________


3PM Slots Ans

________


3PM Slots Ans

______________


3PM Slots Ans

______________


____________

3PM Slots Ans

____________


  • You are given Q queries. Each query contains a number N= Query[i] denoting the query

  • You have to find M such that :

  • * 1<=M<=N.
  • * M| M+1 | ... | N is a maximum as possible, where | is the OR bitwise operation
  • * M is as maximum possible .
  • * The answer to this query is the value of M.

  • Find the sum of answers to all queries modulo 10 pow 9 +7

  • Code please
  • 3PM Slots Ans
______________

  • package com.ajit.String;

  • import java.util.HashSet;
  • import java.util.Scanner;
  • import java.util.Set;

  • public class Main {
  •  public static void main(String[] args) {
  •   Scanner sc = new Scanner(System.in);
  •   int N = sc.nextInt();
  •   int K = sc.nextInt();
  •   String S = sc.next();
  •   int result = solve(N, K, S);
  •   System.out.println(result);

  •  }

  •  public static int solve(int N, int K, String S) {
  •   int MOD = (int) Math.pow(10, 7);

  •   Set<String> substrings = new HashSet<>();
  •   for (int i = 0; i <= N - K; i++) {
  •    substrings.add(S.substring(i, i + K));
  •   }

  •   int count = 0;
  •   for (String substring : substrings) {
  •    Set<String> permutations = new HashSet<>();
  •    permute("", substring, permutations);
  •    count += permutations.size();
  •    count = count % MOD;
  •   }

  •   return count;
  •  }

  •  public static void permute(String prefix, String str, Set<String> permutations) {
  •   int n = str.length();
  •   if (n == 0) {
  •    permutations.add(prefix);
  •   } else {
  •    for (int i = 0; i < n; i++) {
  •     permute(prefix + str.charAt(i), str.substring(0, i) + str.substring(i + 1, n), permutations);
  •    }
  •   }

  •   return;
  •  }
  • }3PM Slots Ans
_____________


Bob was Decorating
Wooden code
Rooted tree 

_______3PM Slots Ans
____
  • Max num of contests u can organise using bob

  • Code please

  • Nagapavan Yarramsetti:
  • You are given Q queries. Each query contains a number N= Query[i] denoting the query

  • You have to find M such that :

  • * 1<=M<=N.
  • * M| M+1 | ... | N is a maximum as possible, where | is the OR bitwise operation
  • * M is as maximum possible .
  • * The answer to this query is the value of M.

  • Code please

  • Find the sum of answers to all queries modulo 10 pow 9 +7
  • Solution: 
  • import java.util.Scanner;

  • public class Main {
  •     public static final int MOD = (int)1e9 + 7;

  •     public static void main(String[] args) {
  •         Scanner sc = new Scanner(System.in);
  •         int T = sc.nextInt();
  •         long sum = 0;
  •         while (T-- > 0) {
  •             int N = sc.nextInt();
  •             int M = 0;
  •             for (int i = 30; i >= 0; i--) {
  •                 if (((N >> i) & 1) == 1) {
  •                     M = (M << 1) + 1;
  •                 } else {
  •                     M = (M << 1);
  •                 }
  •             }
  •             sum = (sum + M) % MOD;
  •         }
  •         System.out.println(sum);
  •     }
  • }
  • 3PM Slots Ans

___________


3PM Slots Ans

___________


  • Solution:
  • def count_bitwise_and_zero(nums: List[int]) -> int:
  •     def get_set_bit_indices(x: int) -> List[int]:
  •         """Return indices of set bits in x"""
  •         pow_2 = 1
  •         exponent = 0
  •         set_bits = []

  •         while pow_2 <= x:
  •             if pow_2 & x != 0:
  •                 set_bits.append(exponent)

  •             exponent += 1
  •             pow_2 *= 2

  •         return set_bits

  •     def is_bitwise_and_zero(window_length: int, bit_counts: Dict[int, int]) -> bool:
  •         return all(value < window_length for value in bit_counts.values())

  •     n = len(nums)
  •     total_subarray_count = n * (n + 1) // 2

  •     nonzero_subarray_count = 0
  •     window_bit_counts = Counter()

  •     """At every iteration start, [left_idx, right_idx] is the longest subarray
  •     ending at right_idx whose bitwise AND is nonzero."""
  •     left_idx = 0

  •     for right_idx, right_element in enumerate(nums):
  •         if right_element == 0:
  •             window_bit_counts.clear()
  •             left_idx = right_idx + 1
  •             continue

  •         window_bit_counts += Counter(get_set_bit_indices(right_element))
  •         while (left_idx < right_idx
  •                and is_bitwise_and_zero(right_idx - left_idx + 1, window_bit_counts)):

  •             window_bit_counts -= Counter(get_set_bit_indices(nums[left_idx]))
  •             left_idx += 1

  •         nonzero_subarray_count += (right_idx - left_idx + 1)

  •     return total_subarray_count - nonzero_subarray_count 
______3PM Slots Ans
______ 
  •  

    Solution : array AR of size N

    perfect_sum(arr, s, result) :
    x = [0]*len(arr)
    j = len(arr) – 1

    while (s > 0) :
    x[j] = s % 2
    s = s // 2
    j -= 1
    sum = 0
    for i in range(len(arr)) :
    if (x[i] == 1) :
    sum += arr[i]
    if (sum == result) :
    print(“{“,end=””);
    for i in range(len(arr)) :
    if (x[i] == 1) :
    print(arr[i],end= “, “);
    print(“}, “,end=””)

    def print_subset(arr, K) :
    x = pow(2, len(arr))
    for i in range(1, x):
    perfect_sum(arr, i, K)

    # Driver code
    arr = [ ]
    n = int(input(“Enter length of array : “))
    s=int(input(“Enter sum : “))
    for i in range(n):
    ele=int(input(“Enter element : “))
    arr.append(ele)
    print_subset(arr, s)

     ____________________

    Find all subarray index ranges in given Array with set bit sum equal to X

    Given an array arr (1-based indexing) of length N and an integer X, the task is to find and print all index ranges having a set bit sum equal to X in the array.

    Examples:

     

    Input: A[] = {1 4 3 5 7}, X = 4

    Output:  (1, 3), (3, 4)

    Explanation: In the above array subarray having set bit sum equal to X (= 4).

    Starting from index 1 to 3. {1 4 3}  = (001) + (100) + (011) = 4  and

    other one is from 3 to 4 {3, 5} = (011) + (101) = 4.

     

    Input: arr[] = {5, 3, 0,  4, 10}, X = 7

    Output:  (1 5)

     

    Solution :

    def countSetBit(arr, n):

        c = 0

     

        for i in range(n):

            x = arr[i]

            while (x):

                l = x % 10

                if (x & 1):

                    c += 1

                x = x // 2

            arr[i] = c

            c = 0

    def PrintIndex(arr, N, X, v):

     

        i,j,currSum = 0,0,arr[0]

     

        while (j < N and i < N):

     

            if (currSum == X):

                     

     

                v.append(i + 1)

                v.append(j + 1)

     

                j += 1

                if(j<N):

                    currSum += arr[j]

            elif (currSum < X):

                j += 1

                if(j<N):

                    currSum += arr[j]

            else:

                currSum -= arr[i]

                i += 1

     

    # Driver code

    v = [1, 4, 3, 5, 7]

    X = 4

    N = len(v)

    countSetBit(v, N)

    ans = []

    PrintIndex(v, N, X, ans)

     

    for i in range(0,len(ans) - 1,2):

        print(f"({ans[i]} {ans[i + 1]})",end=" ")

     

    ______________________________

     


    Soluion  1:

    def findXor(arr,n):

     

        # Calculate xor of

        # all the elements

        xoR = 0;

        for i in range (0, n ) :

            xoR = xoR ^ arr[i]

        

        # Return twice of

        # xor value

        return xoR * 2

     

    # Driver code

    arr = [ 1, 5, 6 ]

    n = len(arr)

    print(findXor(arr, n))

     

     

    Solution 2:

    def findXorSum(arr, n):

        

        # variable to store the final Sum

        Sum = 0

     

        # multiplier

        mul = 1

     

        for i in range(30):

            c_odd = 0

            odd = 0

            for j in range(n):

                if ((arr[j] & (1 << i)) > 0):

                    odd = (~odd)

                if (odd):

                    c_odd += 1

            for j in range(n):

                Sum += (mul * c_odd)

     

                if ((arr[j] & (1 << i)) > 0):

                    c_odd = (n - j - c_odd)

     

            mul *= 2

        return Sum

    arr = [3, 8, 13]

     n = len(arr)

     print(findXorSum(arr, n))

     ____________________



    #include<iostream>
    #include<unordered_map>
    #include<string>
    #include<math.h>
    using namespace std;
    int ans(string s){
    unordered_map map;
    for(int i =0; i map[s[i]]){
    } }
    return val; }
    int main() {
    string s;
    cin>>s;
    cout<< ans(s);
    return 0; }
    val = map[s[i]];
    key = map[s[i]];

    C++

    __________________

     

    Solution :

    def findMax(arr, n):

        large, index = 0, 0

        for i in range(n):

            if arr[i] > large:

                large = arr[i]

                index = i

     

        # return the index of the maximum element

        return index

     

     

    def countSteps(arr, n):

         index = findMax(arr, n)

        steps = 1

        while index != 0:

            index = findMax(arr, index)

            steps += 1

     

        return steps

    if __name__ == "__main__":

        arr = [2, 5, 8, 24, 4, 11, 6, 1, 15, 10]

        n = len(arr)

        print("Steps Taken:", countSteps(arr, n))

     _________________

     

     

    Solution :

    def findValue(arr, n):

        a = []

        b = []

        for i in range(n):

            a.append(arr[i] + i)

            b.append(arr[i] - i)

     

        x = a[0]

        y = a[0]

     

        for i in range(n):

            if (a[i] > x):

                x = a[i]

     

            if (a[i] < y):

                y = a[i]

     

        ans1 = (x - y)

     

        x = b[0]

        y = b[0]

        for i in range(n):

            if (b[i] > x):

                x = b[i]

     

            if (b[i] < y):

                y = b[i]

     

        ans2 = (x - y)

     

        return max(ans1, ans2)

     

    if __name__ == '__main__':

        arr = [1, 2, 3, 1]

        n = len(arr)

     

        print(findValue(arr, n))

     

     _____________

     


    Solution :

    def getMaxToys(n,arr,money):

        L,H=0,n-1

        while(L<=H):

            if(sum(arr[L:H+1])<=money):

                break

            else:

                if arr[L]>arr[H]:

                    L+=1

                else:

                    H-=1

        return (H-L+1)

       

    n=int(input())

    arr=[]

    for i in range(n):

        arr.append(int(input()))

    money=int(input())

    print(getMaxToys(n,arr,money))

     

    max = 4

    # Recursive function to find the

    # required number of ways

    def countWays(index, cnt, dp, n, m, k):

        # When all positions are filled

        if (index == n) :

            # If adjacent pairs are exactly K

            if (cnt == k):

                return 1

            else:

                return 0

        # If already calculated

        if (dp[index][cnt] != -1):

            return dp[index][cnt]

         ans = 0

         # Next position filled with same color

        ans += countWays(index + 1, cnt, dp, n, m, k)

         # Next position filled with different color

        # So there can be m-1 different colors

        ans += (m - 1) * countWays(index + 1,

                                   cnt + 1, dp, n, m, k)

         dp[index][cnt] = ans

        return dp[index][cnt]

     # Driver Code

    if __name__ == "__main__":

            n = 3

        m = 3

        k = 2

        dp = [[-1 for x in range(n + 1)]

                  for y in range(max)]

        print(m * countWays(1, 0, dp, n, m, k))

    ________________


    array AR of size N

    perfect_sum(arr, s, result) :
    x = [0]*len(arr)
    j = len(arr) – 1

    while (s > 0) :
    x[j] = s % 2
    s = s // 2
    j -= 1
    sum = 0
    for i in range(len(arr)) :
    if (x[i] == 1) :
    sum += arr[i]
    if (sum == result) :
    print(“{“,end=””);
    for i in range(len(arr)) :
    if (x[i] == 1) :
    print(arr[i],end= “, “);
    print(“}, “,end=””)

    def print_subset(arr, K) :
    x = pow(2, len(arr))
    for i in range(1, x):
    perfect_sum(arr, i, K)

    # Driver code
    arr = [ ]
    n = int(input(“Enter length of array : “))
    s=int(input(“Enter sum : “))
    for i in range(n):
    ele=int(input(“Enter element : “))
    arr.append(ele)
    print_subset(arr, s)

    Python

____3PM Slots Ans
___________




__
3PM Slots Ans
_______
  • public class XOR {
  •     public static int findMaxOverlappingSegments(int[] A) {
  •         int N = A.length;
  •         int[][] dp = new int[N+1][N+1];
  •         for (int i = 1; i <= N; i++) {
  •             dp[i][i] = 0;
  •         }
  •         for (int i = 1; i <= N; i++) {
  •             for (int j = i+1; j <= N; j++) {
  •                 dp[i][j] = -1;
  •             }
  •         }
  •         for (int len = 2; len <= N; len++) {
  •             for (int i = 1; i <= N-len+1; i++) {
  •                 int j = i+len-1;
  •                 int xor = 0;
  •                 for (int k = i; k <= j; k++) {
  •                     xor = xor ^ A[k-1];
  •                 }
  •                 if (xor == 0) {
  •                     dp[i][j] = Math.max(dp[i][j-1], dp[i][j-1] + dp[j][j] + 1);
  •                 } else {
  •                     dp[i][j] = dp[i][j-1];
  •                 }
  •             }
  •         }
  •         return dp[1][N];
  •     }
  •     public static void main(String[] args) {
  •         int[] A = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  •         System.out.println(findMaxOverlappingSegments(A));
  •     }
  • }
_________3PM Slots Ans
_____

  • 1.You have an array A of length N and two empty baskets
  • 2.You are given an array Arr of size N
  • 3.You have an weighted tree, rooted at vertex 1 that consists of N vertices and N-1 undirected edges it is given that we define path benefit as the minimum weight in the path
_______3PM Slots Ans
______

  • Submask 
  • Empty baskets
  • Non empty sub set
  • Smallest lexicographical array
  • Minimum poosibble cost 
  • 10^9+7
  • 1)You are given an array A with permutation P with length N.
  • 2) find total number of ways to participation A.
  • 3) find the total number of elements in good term.
  • 1. Find the lexicographical array possible after swapping 
  • 2.find the sum of F(i) for all where (1<=i<=N) and (I!=s). Since the answer might be large return it modulo 10^9+7
______3PM Slots Ans
________


  • import itertools

  • def permutation_cost(s):
  •     # Get all possible permutations of the first 20 lowercase English letters
  •     permutations = list(itertools.permutations(s))
  •     # Set initial minimum cost to a large number
  •     min_cost = float('inf')
  •     for perm in permutations:
  •         cost = 0
  •         # Iterate through the permutation
  •         for i in range(len(perm) - 1):
  •             # If the next letter appears before the current letter in the permutation, add 1 to the cost
  •             if perm[i] > perm[i + 1]:
  •                 cost += 1
  •         # Update minimum cost if necessary
  •         min_cost = min(min_cost, cost)
  •     return min_cost

  • s = 'abcdefghijklmnopqrstuvwxyz'[:20]
  • print(permutation_cost(s))import itertools

  • def permutation_cost(s):
  •     # Get all possible permutations of the first 20 lowercase English letters
  •     permutations = list(itertools.permutations(s))
  •     # Set initial minimum cost to a large number
  •     min_cost = float('inf')
  •     for perm in permutations:
  •         cost = 0
  •         # Iterate through the permutation
  •         for i in range(len(perm) - 1):
  •             # If the next letter appears before the current letter in the permutation, add 1 to the cost
  •             if perm[i] > perm[i + 1]:
  •                 cost += 1
  •         # Update minimum cost if necessary
  •         min_cost = min(min_cost, cost)
  •     return min_cost

  • s = 'abcdefghijklmnopqrstuvwxyz'[:20]
  • print(permutation_cost(s))
_________3PM Slots Ans
________

3PM Slots Ans

____________


3PM Slots Ans

___________




2 baskets array solution!
_________




_________

Smallest lexicographical array Minimum possible cost

_______

  • given an array A of size N.

  • You are allowed to choose at most one pair of elements such that distance (defined as the difference of their indices) is at most K and swap them.

  • Find the smallest lexicographical array possible after

  • Notes:

  • An array x is lexicographically smaller than an array y if there exists an index i such that xi <y i1 and x_{j} = y_{j} for all 0 <= j < i . Less formally, at the first index i in which they differ xi < yi
  • Input Formats@gman

  • The First-line contains Integers N Ea an integer, N, denoting the line i of the N subsequent lines (where describing A[i]. of elements in A. N) contains an integer 

  • The next line contains an integer, K, denoting the upper bound on distance of index.

  • Constraints
  • Here as all the array values are equal swapping will not change the final result,

  • Here A=[5,4,3,2,11 K we can swap elements at index 0 and index 3 which makes A= [2,4,3,5,1].

  • Here A=[2,1,1,1,1] K we can swap elements at index 0 and index 3 chat which makes A= [1.1.1.2.11

  • bool swapped = false;
  •     for (int i = 0; i < N - 1; i++) {
  •         for (int j = i + 1; j <= min(i + K, N - 1); j++) {
  •             if (A[i] > A[j]) {
  •                 swap(A[i], A[j]);
  •                 swapped = true;
  •                 break;
  •             }
  •         }
  •         if (swapped) break;
  •     }
  •     if (!swapped) return A;
  •     else return A;

  • C++
__________

Longest Subsquence 
Python

_______



________


_________


_______




___________

  • You are given a rooted tree of N vertices and an array A of N integers A[i] is the parent of the vertex (i+1 or 0 if the vertex (i+1) is the root.
  • For each vertex V from 1 to N, the answer K is the total number of subsets of vertices with the LCA (lowest common ancestor) equal to V Since the of K can be large calculate it modulo 10 ^ 9 + 7
  • Let there be an integer array Res where Res[i] contains the answer for (I + 1)th  vertex, Find the array Res
  • Notes:
  • • The lowest common ancestor (LCA) is defined for X nodes A1, A2,.... Ax as the lowest node in the tree that has all A1 A2..... Ax as descendants (where we allow a node to be a descendant of itself)

  • Input Formate
  • The first line contains an integer N denoting the number of elements in A
  • Each line 1 of the N subsequent lines (where 0<=i<N) contains an integer
  • describing All It is given that A[i] denotes the parent of the vertex (i+1) or 0
  • If the vertex (i+1) is the root

  • const int N = 100005;
  • const int MOD = 1e9 + 7;
  • int  a[N], dp[N], res[N];
  • vector<int> g[N];
  • void dfs(int u) {
  •     dp[u] = 1;
  •     for (int v : g[u]) {
  •         dfs(v);
  •         dp[u] = 1ll * dp[u] * (dp[v] + 1) % MOD;
  •     }
  •     res[u] = (1ll * dp[u] * (1 << g[u].size()) - 1 + MOD) % MOD;
  • }

  • vector<int> functionName(int n,vector<int>A)
  • {
  •     g=A;
  •     dfs(1);
  •     return res;
  • }
  •    
  • Language c++
  • Infosys 
____________

  • You are given an f length N and an array B of length M.

  • You need to find the longest possible sub-sequence (not necessarily of consecutive elements) of A such that it does not have amay B as a sub-arrey elements).

  • Find the length of the such sub-sequence.

  • A subsequence is a sequence that can be derived sequence by deleting some or no elements without changing the order of the • A subarray is a contiguous part of an array and maintains a relative ordering of elements. 

  • Input Format

  • The first line contains an integer, N, denoting the size of array A.

  • Each line i of the N subsequent lines (where 0 ≤i≤N) contains an I integer describing A[i] 


  • The next line contains an integer, M, denoting the size of array B.

  • Each line i of the M subsequent lines (where 0 ≤i≤ M) contains a an integer describing B[i].

  • Constraints

  • 1 <= N <= 500

  • 1 <= A[i] <= 100

  • 1 <= M <= N

  • 1 <= B[i] <= 100


  • N=4 A= [4, 4, 4. 4) M= 2 B= [4, 4] if you take any sub-sequence longer than 1, then array B will be the subarray of the chosen subsequence, so the answer here is 1.

  • N=5A [1, 2, 3,4,M =2 B=[6, 7] Since there is no common element between A and B, the longest subsequence answer is 5. we can choose is complete A hence the answer is 5

  • ____
  • N=5A= [1, 2, 3, 4, 5] M = 3 B = [1, 2, 3] we can not choose complete A since B will be a subarray of that so choose [1,2,4,5] as a subsequence and B is not a subarray of chosen subsequence hence the answer is 4.

  • func getMax (N int32, A []int32, M int32, B []int32) int32 { write your code here}

____________

  • def minJumps(arr, n):

  •     jumps = [0 for i in range(n)]
  •  

  •     if (n == 0) or (arr[0] == 0):

  •         return float('inf')
  •  

  •     jumps[0] = 0


  •     for i in range(1, n):

  •         jumps[i] = float('inf')

  •         for j in range(i):

  •             if (i <= j + arr[j]) and (jumps[j] != float('inf')):

  •                 jumps[i] = min(jumps[i], jumps[j] + 1)

  •                 break

  •     return jumps[n-1]
  •  
  •  

  • arr = [1,1,1,2,4]

  • n = len(arr)

  • print('Minimum number of jumps to reach end is', minJumps(arr, n))
__________

  • #define ll long long int

  • void divideIt(int& no,int j,unordered_map<int,array<int,2>>& minFreq,
  •                  unordered_map<int,array<int,2>>& secondMinFreq, int idx){
  •     
  •     
  •     int countFreq = 0 ;
  •     while(no%j==0){
  •         no /= j ;
  •         countFreq++;
  •     }
  •     
  •     if( countFreq < minFreq[j][0] ){
  •         
  •         secondMinFreq[j] = {minFreq[j][0],-1} ;
  •         minFreq[j] = {countFreq,idx};
  •     }
  •     else if( countFreq == minFreq[j][0] )
  •         secondMinFreq[j] = {minFreq[j][0],-1} ;
  •     
  •     else if( countFreq > minFreq[j][0] && countFreq < secondMinFreq[j][0] )
  •         secondMinFreq[j] = {countFreq,-1} ;
  • }


  • int calc(int N,int L,int R,vector<int> A,int Q,vector<int> B){
  •     
  •     unordered_map<int, array<int,2> > minFreq;
  •     unordered_map<int, array<int,2> > secondMinFreq;
  •     
  •     unordered_map<int,int> countFreq ;
  •     
  •     for(int i=L-1;i<R;i++){
  •         
  •         int no = A[i] ;
  •         
  •         if(no%2==0)
  •             countFreq[2]++;
  •         
  •         if(!minFreq.count(2))
  •             minFreq[2] = {INT_MAX,int(-1)} ;
  •         if(!secondMinFreq.count(2))
  •             secondMinFreq[2] = {INT_MAX,int(-1)} ;
  •         
  •         divideIt(no,2,minFreq,secondMinFreq,i) ;
  •         
  •         for(int j=3;no>1;j+=2){
  •             
  •             if(no%j==0)
  •                 countFreq[j]++;
  •             
  •             if(!minFreq.count(j))
  •                 minFreq[j] = {INT_MAX,-1} ;
  •             if(!secondMinFreq.count(j))
  •                 secondMinFreq[j] = {INT_MAX,-1} ;
  •             
  •             divideIt(no,j,minFreq,secondMinFreq,i) ;
  •         }
  •     }
  •     
  •     for(auto& e:countFreq){
  •         
  •         if( e.second == R-L ){
  •             
  •             if( minFreq[e.first][0] != 0 ){
  •                 for(int i=L-1;i<R;i++)
  •                     if( A[i]%e.first ){
  •                         minFreq[e.first] = {0,i} ;
  •                     }
  •             }
  •         }
  •         
  •         else if( e.second < R-L  ){
  •             minFreq[e.first]={0,0} ;
  •             secondMinFreq[e.first]={0,-1} ;
  •         }
  •         
  •     }
  •     
  •     int countGood = 0 ;
  •     
  •     for(auto e:B){
  •         
  •         int minIdx = -1 ;
  •         bool isP = true ;
  •         
  •         int count2=0;
  •         while(e%2==0){
  •             e /=2 ;
  •             count2++;
  •         }
  •         
  •         if( minFreq[2][0] < count2 )
  •             minIdx = minFreq[2][1] ;
  •         
  •         if(secondMinFreq[2][0]<count2)
  •             isP=false;
  •         
  •         
  •         for(int i=3;e>1;i+=2){
  •             
  •             int countI = 0 ;
  •             while(e%i==0){
  •                 e /= i ;
  •                 countI++;
  •             }
  •             
  •             if( secondMinFreq[i][0] < countI )
  •                 isP=false;
  •             
  •             if( minFreq[i][0] < countI && minIdx!=-1 && minFreq[i][0] != minIdx )
  •                 isP = false;
__________

  • def longest_subsequence(A):
  •     n = len(A)
  •     dp = [1] * n # create an array to store the longest subsequence ending at each index
  •     for i in range(1, n):
  •         for j in range(i):
  •             if A[j] > A[i] and dp[j] + 1 > dp[i]:
  •                 dp[i] = dp[j] + 1
  •     return max(dp)
________


__________

  • perfect_sum(arr, s, result) :
  • x = [0]*len(arr)
  • j = len(arr) – 1
  • while (s > 0) :
  • x[j] = s % 2
  • s = s // 2
  • j -= 1
  • sum = 0
  • for i in range(len(arr)) :
  • if (x[i] == 1) :
  • sum += arr[i]
  • if (sum == result) :
  • print(“{“,end=””);
  • for i in range(len(arr)) :
  • if (x[i] == 1) :
  • print(arr[i],end= “, “);
  • print(“}, “,end=””)
  • def print_subset(arr, K) :
  • x = pow(2, len(arr))
  • for i in range(1, x):
  • perfect_sum(arr, i, K)
  • # Driver code
  • arr = [ ]
  • n = int(input(“Enter length of array : “))
  • s=int(input(“Enter sum : “))
  • for i in range(n):
  • ele=int(input(“Enter element : “))
  • arr.append(ele)
  • print_subset(arr, s)
___________






Compensation For Infosys Off-Campus Drive 2022:

  • The compensation for the Specialist Programmer role is INR 9.5 lakhs per annum and 
  • for the Digital Specialist Engineer role it is INR 6.25 lakhs per annum

Infosys Latest Detailed Eligibility Criteria: Infosys SP and DSE:

Infosys Latest Detailed Eligibility Criteria: Infosys SP and DSE
  • infosys sp dse coding questions | infosys coding | infosys sp dse role | infosys sp dse exam | infosys coding test | zero coding infosys | infosys coding round | infosys coding questions | zero coding infosys drive | zero coding infosys recruitment | infosys dse role | infosys coding questions for sp and dsp | zero coding infosys off campus | infosys coding round questions | infosys specialist programmer coding questions | infosys coding questions in python | infosys

  • infosys sp dse coding questions | infosys sp dse role | infosys sp dse exam | infosys coding questions | infosys programming questions | infosys coding questions for sp and dsp | infosys coding practice questions | infosys coding round questions | infosys dse and sp role preparation | infosys dse role | infosys programming questions specialist | infosys coding questions in python | infosys coding interview questions | infosys specialist programmer coding questions

  • infosys sp dse coding questions | infosys sp dse exam | infosys sp dse role | infosys coding questions and answers in python | infosys sp dse exam pattern | infosys coding questions | infosys sp dse role coding questions | infosys coding interview questions | infosys coding round questions | infosys coding questions and answers | infosys coding questions in python | infosys coding questions for sp and dsp | infosys | infosys sp dse result | infosys sp dse interview experience

  • infosys sp dse coding questions | infosys coding questions and answers in python | infosys sp dse exam | infosys sp dse role coding questions | infosys sp dse exam pattern | infosys sp dse role | infosys coding questions | infosys coding questions and answers | infosys coding interview questions | infosys coding questions in python | infosys coding round questions | infosys coding questions for sp and dsp | infosys sp dse result | infosys | infosys sp dse interview experience

How To Apply for Infosys Recruitment Drive 2022:  

All candidates can apply for the Infosys Off-Campus Recruitment Drive 2022, they may apply for this position by clicking on the link given below before the link expire:

Join Our What's App Group

Step#1: Go to the above link, Join Our What's App Group.

Step#2: Apply Link: Click The Below Link To Apply

Apply Link: Click here (Recruitment Drive)

Preparation Materials Link: Click here (PDF Download)

Note: Apply for The Job Before Link Expires.

Infosys Off-Campus Drive 2022 – Frequently Asked Questions
How to Apply for Infosys Off-Campus 2022 Drive?
To apply for the Infosys Off Campus Drive, candidates must visit the official site at Infosys.com. Or else, check FreshersocJob.com to get the direct application link.
What is the Infosys Off-Campus Selection Process?
Online Written Test, Technical Interview, HR Interview.
Does FreshersocJob provide Infosys Job Updates?
Yes, FreshersocJob provides Infosys Job Updates.
Does FreshersocJob provide Infosys Placement Papers?
Yes, FreshersocJob provides Infosys Placement papers to find it under the FreshersocJob placement papers section
For More Detailed Information Regarding Placement Guides all Types of Updates Visit my Youtube Channel - Pappu Career Guide.

Also, Read More about this, 

Stay tuned with www.freshersocjob.com to receive more such updates on recruitment. Join our Telegram Channel and Join our WhatsApp Group To get Instant updates for All Recruitment Internships and Off-Campus of 2021 Pass-Out Batch and Other Batch.


Comments