0% found this document useful (0 votes)
6 views

Repeated Coding Solution_

The document contains a series of programming tasks and code snippets that require modification to avoid plagiarism. Each task includes a brief description and associated code, which needs to be rewritten or restructured. The tasks cover various topics including palindromes, frequency counting, and maximum subarray calculations.

Uploaded by

rockyv9964
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Repeated Coding Solution_

The document contains a series of programming tasks and code snippets that require modification to avoid plagiarism. Each task includes a brief description and associated code, which needs to be rewritten or restructured. The tasks cover various topics including palindromes, frequency counting, and maximum subarray calculations.

Uploaded by

rockyv9964
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

CHANGE ALL THE CODES TO AVOID PLAGIARISM :-

1.Harold and his


homework:

NOTE: Here, m=input2


d=input3

2.Halindrome:
(​change it as per the question​)
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-

Abraham :

Planting Trees:
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-

Frequency co:
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-

Monica and flavours some errors:

Social Network
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-

LCS with Vowels


str1 = input()
str2 = input ()
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-
vowels = 'aeiou'
c1 = c2 = 0
for ch in str1:
if ch in vowels:
c1 += 1
for ch in str2:
if ch in vowels:
c2 += 1
print(min(c1,c2))

Longest palindromic subsequence

Bob and Numbers


CHANGE ALL THE CODES TO AVOID PLAGIARISM :-

n = int(input())
a = list(map(int,input().split()))
c=0
for i in range(n-1):
for j in range(i+1:n):
s1 = sum(list(map(int,bin(i)[2:].split())))
s2 = sum(list(map(int,bin(j)[2:].split())))
if s1 == s2:
c += 1
print(c

apple orchard solution


Sort the array .
Initialize a max = 0
iterate a loop on sorted array.
suppose sorted arr[] ={48,80,82}
now iterate
for (int i = 0 ; i < n ; i++)
{
int temp = arr[i] * (n-i+1);
if (temp > max)
{
max = temp;
}
} // end of for loop
Print(max)

New----

n = int(input())
l = list(map(int,input().split()))
res = min(l)*n
print(res)
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-

Evaluate a given infix expression


Use eval() in python

Maximum subarray
def maxSubArray(self, nums: List[int]) -> int:
max_sub_sum = 0
prev_max = 0
for num in nums:
prev_max = max(prev_max + num, num)
max_sub_sum = max(prev_max, max_sub_sum)

#if max is 0 and 0 not in list it means that there is no num in subarray, so we choose max num from list
if max_sub_sum is 0 and 0 not in nums:
max_sub_sum = max(nums)

return max_sub_sum
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-

MOVING APPLES
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-
NEXT GENERATOR NUMBER
class Solution {
public int[] nextGreaterElements(int[] nums) {
int[] output=new int[nums.length];
int n=nums.length;
Arrays.fill(output,-1);
Stack<Integer> stk=new Stack();

for(int i=0;i<n*2;i++){

while(!stk.isEmpty() && nums[stk.peek()]<nums[i%n]){

output[stk.pop()]=nums[i%n];
}

if(i<n) stk.push(i);

}
return output;

}
}

Selective arrangements
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-

Permutation combination

Typeyour
Type yourtext
Type text texty
your
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-

Abraham:
n=int(input())

a= {i:i for i in range(n)}


#print(a)
while(len(a)>1):
l=[]
for i in range(0,len(a),2):
l.append(i)
#print('l=',l)
for i in l:
a.pop(i)
#print(i)
#print(a)
counter=0
d1={}
for i in a:
key=i
val=a[i]
#a.pop(key)
d1[counter]=val
counter+=1
#print(a)
a=dict(d1)
#print(a)
#input()
print(a[0])
CHANGE ALL THE CODES TO AVOID PLAGIARISM :-

Think a number:

You might also like