Infosys Coding Solution 29 July 3 PM Slot

Infosys Coding Solution 29 July 3 PM Slot

Infosys Code 1

Number Of Subsequences Code For Infosys

int A[] = 10,13,7,8,14,11;
int n = 6;

int memo[6];//initialized with -1s;

int count(int currIndex)
if (currIndex == n-1) return 1;
if (memo[currIndex] != -1) return memo[currIndex];

int res = 0;
for (int i=currIndex+1 ; i<n ; i++)
if (abss(A[currIndex] – A[i]) <= 3)
res += count(i);

memo[currIndex] = res;
return res;

c++

///////////////////////////////////////////////////////////////////////////////////////

Infosys Code 2

def minOperations(arr1, arr2, i, j):

# Base Case

if arr1 == arr2:

return 0

if i >= len(arr1) or j >= len(arr2):

return 0

# If arr[i] < arr[j]

if arr1[i] < arr2[j]:

# Include the current element

return 1 \

+ minOperations(arr1, arr2, i + 1, j + 1)

# Otherwise, excluding the current element

return max(minOperations(arr1, arr2, i, j + 1),

minOperations(arr1, arr2, i + 1, j))

# Function that counts the minimum

# moves required to sort the array

def minOperationsUtil(arr):

brr = sorted(arr);

# If both the arrays are equal

if(arr == brr):

# No moves required

print(“0”)

# Otherwise

else:

# Print minimum operations required

print(minOperations(arr, brr,)

Python

//////////////////////////////////////////////////////////////////////////////////////////////////////////

Infosys Code 3

Minswap
C++ language
Link: https://linktr.ee/jobforfresher.in

Telegram: https://t.me/jobforfreshars

Share This Info To Your Friends and WhatsApp Group.

//////////////////////////////////////////////////////////

Infosys Code 4

# to make a given change V

import sys

# m is size of coins array (number of different coins)

def minCoins(coins, m, V):

# base case

if (V == 0):

return 0

# Initialize result

res = sys.maxsize

# Try every coin that has smaller value than V

for i in range(0, m):

if (coins[i] <= V):

sub_res = minCoins(coins, m, V-coins[i])

# Check for INT_MAX to avoid overflow and see if

# result can minimized

if (sub_res != sys.maxsize and sub_res + 1 < res):

res = sub_res + 1

return res

# Driver program to test above function

coins = [9, 6, 5, 1]

m = len(coins)

V = 11

print(“Minimum coins required is”,minCoins(coins, m, V))

Python 3
program to find minimum of coins Code

//////////////////////////////////////////////////////////////////

Infosys Code 5

C++
Lexographically smallest question codeINFOSYS EXAM CODE

Link: https://linktr.ee/jobforfresher.in

Telegram: https://t.me/jobforfreshars

👉 Share This Info To Your Friends and WhatsApp Group🙏

//////////////////////////////////////////

Infosys Code 6

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

///////////////////////////////////////////////////////////////////

Infosys Code 7

About Engineer voice

Engineer Voice is an informative platform that provides technical and career growth assistance to students pursuing fields such as B.Tech, BSc, BCA, B.com etc. It includes information on upcoming off-campus hiring drives at no cost.


Thank You for Giving Your Precious Time To Our Website.
For Any Query Comment Us In Comment Box

All Logos & Trademarks Belongs to Their Respective Owners.

Leave a Comment

Internship | Recruitment Drive For 2022 and 2023 Pass Out Engineers Recruitment Drive For 2022 and 2023 Pass Out Engineers Fresher Jobs | Tech Mahindra | Amphora | Citi Hiring Everything You Need to Know to Become a Computer Engineer Without CS Degree Elon Musk Cutting 10% of Tesla Salaried Employees