AD1

Friday, 22 December 2017

Reverse words in a given string

Problem

https://practice.geeksforgeeks.org/problems/reverse-words-in-a-given-string/0

Solution

#problem link
# https://practice.geeksforgeeks.org/problems/reverse-words-in-a-given-string/0
#code
T=int(input())#Test cases
for t in range(0,T):#looping through all test cases
string=[x for x in input().split(".")]
print(*string[::-1],sep='.')
view raw T1.py hosted with ❤ by GitHub
 

Sunday, 17 December 2017

Key Pair
Problem :
 https://practice.geeksforgeeks.org/problems/key-pair/0
Solution
#code
T=int(input())#Test cases
for t in range(0,T):#looping through all test cases
N_X = [int(x) for x in input().split()]
flag=0
A=[int(y) for y in input().split()]#read elements separated by space
for a in range(N_X[0]):
if N_X[1]-A[a] in A:#if number complement found in A[] print yes
print("Yes")
flag=1
break
if(flag==0):
print("No")
view raw KeyPair.py hosted with ❤ by GitHub