Wipro Coding Questions
Wipro Coding Questions
h>
using namespace std;
int main() {
if (mini != -1)
cout << mini;
else
cout << "Invalid inputs";
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
if(a[j]>a[j+1]){
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
string str;
cin>>str;
int hour,minute;
hour=(str[0]-'0')*10 + str[1]-'0';
minute=(str[3]-'0')*10 + str[4]-'0';
int res=0;
minute++;
if(minute==60){
minute=0;
hour++;
}
if(hour==24)
hour=0;
res++;
}
cout<<res;
return 0;
}
Example 1:
Input:
3
123
456
789
Output:
123698745
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int k = 0, l = 0;
if (k < row){
for (int i = col - 1; i >= l; i--)
cout<<a[n - 1][i]<<" ";
row--;
}
if (l < col){
for (int i = row - 1; i >= k; --i)
cout<<a[i][l]<<" ";
l++;
}
}
return 0;
}
k += 1
n -= 1
m -= 1
l += 1
# Driver Code
a = [ [1, 2, 3, 4, 5, 6],
[7, 8, 9, 10, 11, 12],
[13, 14, 15, 16, 17, 18] ]
R = 3; C = 6
spiralPrint(R, C, a)
Trapezium question
#include<stdio.h>
int main ()
{
int n = 5, num = 1, i = 1, space = 0, k = 1, number = n;
num--;
for(int i=n;i>=1;i--)
{
for(int j=1;j<=i;j++)
cout<<num;
num--;
cout<<endl;
}
return 0;
}
#include <iostream>
using namespace std;
int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
int main()
{
int a,b;
cin>>a;
cin>>b;
cout<<gcd(a,b);
return 0;
}
#include <stdio.h>
int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
void main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
int res=gcd(a,gcd(b,c));
printf("%d",res);
}
n = int(input())
ar = list(map(int, input().split()))
print(sockMerchant(n, ar))
steps = int(input())
path = input()
print(countingValley(steps, path))
def rotateLeft(n,d,arr):
for i in range(d):
arr = rotatearr(n,arr)
return arr
, d = map(int, input().split())
arr = list(map(int, input().split()))
for i in rotateLeft(n,d,arr):
print(i, end=" ")
a = [[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]
b = [[1,1,1,1],[2,2,2,2],[3,3,3,3],[4,4,4,4]]
if a==b:
prin("Metrices are identical")
else:
pint("Metrices are not identical")
def pythagoreanTriplets(limit):
a = b = c = 0
m = 2
while True:
for n in range(1,m+1):
a = m*m - n*n
b = 2*m*n
c = m*m + n*n
if c > limit:
break
if a==0 or b==0 or c==0:
break
print(a,b,c)
m=m+1
limit = int(input())
pythagoreanTriplets(limit)