You are on page 1of 4

Remove character ->https://practice.geeksforgeeks.

org/problems/remove-character/0

t=int(input())

while t>0:

s1=input()

s2=input()

for i in s2:

if i in s1:

s1=s1.replace(i,'')

print(s1)

t=t-1

Multiply left and right array sum -> https://practice.geeksforgeeks.org/problems/multiply-left-and-right-


array-sum/0

t = int(input())

while t > 0:

sum1=0

sum2=0

n= int(input())

l1=input().split()

length = len(l1)

length1=length//2

for i in range(length1):

sum1=sum1+int(l1[i])

for i in range(length1,length):

sum2=sum2+int(l1[i])

print(sum1 * sum2 , sep='')

t=t-1
Max value after M range operations ->https://practice.geeksforgeeks.org/problems/max-value-after-m-
range-operation/0

Find the index : https://practice.geeksforgeeks.org/problems/search-in-a-rotated-array/0/?ref=self

**** https://practice.geeksforgeeks.org/problems/majority-element/0/?ref=self

Single iteration :

for t in range(T):

n = int(input())

A = [int(i) for i in input().strip().split()]

K = int(input())

i=0

j = n-1

f=0

while(i!=j):

val = A[i]+A[j]

if(val == K):

f=1

print(A[i], A[j], K)

i += 1

elif(val > K):

j -= 1

else:

i += 1

if(f==0):

print(-1)
OCCURANCE OF X IN BETWEEN A AND B:

t = int(input())

while t>0:

x=input()

counts=0

l=input().split()

for i in range(int(l[0])+1,int(l[1])):

counts=counts+(str(i).count(x))

print(counts)

t=t-1

OR

range_val = [int(x) for x in input().split()]

count = 0

for x in range(range_val[0]+1, range_val[1]):

count += str(x).count(str(digit))

print(count)

Reverse a bin form of a decimal and output(https://practice.geeksforgeeks.org/problems/reverse-


bits/0/?ref=self)

t =int(input())

while t>0:

x=input()

y=bin(int(x)).replace("0b","")

y=y.zfill(32)

l1=[]

for i in reversed(y):

l1.append(i)

y1=''.join(l1)

print(int(y1,2))
t=t-1

https://practice.geeksforgeeks.org/problems/swap-all-odd-and-even-bits/0/?ref=self
arr = list(map(int,input().split()))

Pair with given sum in a sorted array : https://practice.geeksforgeeks.org/problems/pair-with-


given-sum-in-a-sorted-array/0
t = int(input())

while t>0:

n=int(input())

l=input().split()

i=0

j=int(len(l)-1)

k=int(input())

flag=0

while i<j:

sum=int(l[i])+int(l[j])

if sum==k:

print(l[i],l[j],k)

i=i+1

j=j-1

flag=1

elif sum<k:

i=i+1

else:

j=j-1

if flag==0:

print("-1")

t=t-1

You might also like