القضية رقم 32: التدريب على تكنولوجيا المعلومات - القضايا والتحديات الحالية من الشركات الرائدة

مرحبا ايها القراء. نحن نسعدك مرارًا وتكرارًا بمجموعة جديدة من الأسئلة والمهام المثيرة للاهتمام من المقابلات إلى شركات تكنولوجيا المعلومات الرائدة!

بالمناسبة ، تم بالفعل نشر إجابات مشاكل العدد السابق !



ستظهر المشاكل كل أسبوع - ترقبوا! العمود مدعوم من قبل وكالة التوظيف Spice IT .

قمنا هذا الأسبوع بجمع المهام من المقابلات في شركة MakeMyTrip الهندية.

الأسئلة


1. 10 عملات معدنية اللغز
أنت معصوب العينين و 10 عملات معدنية أمامك على الطاولة. يُسمح لك بلمس العملات المعدنية ، ولكن لا يمكنك معرفة أي طريق يصل إليها عن طريق الشعور. يقال لك أن هناك 5 عملات معدنية مرفوعة ، و 5 عملات معدنية ، ولكن ليس أي منها.

هل يمكنك عمل كميتين من العملات المعدنية لكل منهما بنفس عدد الرؤوس؟ يمكنك قلب العملات المعدنية لأي عدد من المرات.

نقل
10 . , , . , 5 , («») 5 , («») , — .

, ? .

2. لغز الصحيفة
صحيفة من 16 ورقة كبيرة مطوية إلى النصف. تحتوي الصحيفة على 64 صفحة. تحتوي الورقة الأولى على الصفحات 1 ، 2 ، 63 ، 64.

إذا التقطنا ورقة تحتوي على الصفحة رقم 45. ما هي الصفحات الأخرى التي تحتوي عليها هذه الورقة؟

نقل
16 , . 64 . 1, 2, 63, 64.


*

, 45. ?

مهام


1. تبديل المصفوفة
Write a program to find transpose of a square matrix mat[][] of size N*N. Transpose of a matrix is obtained by changing rows to columns and columns to rows.

Input:
The first line of input contains an integer T, denoting the number of testcases. Then T test cases follow. Each test case contains an integer N, denoting the size of the square matrix. Then in the next line are N*N space separated values of the matrix.

Output:
For each test case output will be the space separated values of the transpose of the matrix

Constraints:
1 <= T <= 15
1 <= N <= 20
-103 <= mat[i][j] <= 103


Example:
Input:

2
4
1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
2
1 2 -9 -2


Output:
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
1 -9 2 -2


Explanation:
اختبار 1: المصفوفة بعد الدوران ستكون: 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4.

نقل
, mat[][] N*N. .

:
T, . T . N, . N*N .

:


:
1 < = T <= 15
1 < = N <= 20
-103 < = mat[i] [j] < = 103


:
:

2
4
1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
2
1 2 -9 -2


:
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
1 -9 2 -2


:
1: : 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4.

2. الأصفار الزائدة في عاملي
لعدد صحيح n ابحث عن عدد الأصفار الزائدة في n! .

الإدخال:
يحتوي السطر الأول على عدد صحيح " T " يشير إلى العدد الإجمالي لحالات الاختبار. في كل حالة اختبار ، يحتوي على عدد صحيح " N ".

الإخراج:
في كل سطر منفصل إخراج الإجابة على المشكلة.

المعوقات: مثال: المدخلات: المخرجات:
1 <= T <= 100
1 <= N <= 1000




1
9


1
نقل
n n!.

:
'T', . 'N'.

:
.

:
1 < = T <= 100
1 < = N < = 1000


:
:

1
9

:
1

3. خطوات نايت
Given a square chessboard of N x N size, the position of Knight and position of a target is given. We need to find out minimum steps a Knight will take to reach the target position.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the size of the square chessboard. The next line contains the X-Y coordinates of the knight. The next line contains the X-Y coordinates of the target.

Output:
Print the minimum steps the Knight will take to reach the target position.

Constraints:
1<=T<=100
1<=N<=20
1<=knight_pos,targer_pos<=N


Example:
Input:

2
6
4 5
1 1
20
5 7
15 20


Output:
3
9

N x N . , , .

:
T, . T . n, . X-Y . X-Y .

:
, , .

:
1<=T<=100
1<=N<=20
1<=knight_pos,targer_pos<=N


:
:

2
6
4 5
1 1
20
5 7
15 20


:
3
9


1
: .
:
2 . .

:
— , — .
1:
2:

1.
1:
2:

.

2
45- 46. , P, 65-p .

,
65-45 = 20
65-46 = 19

, — 19, 20, 45, 46.

1
O(1) :
import java.util.*;
import java.lang.*;
import java.io.*;
class GFG
 {
	public static void main (String[] args)
	 {
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 try{
	     int testCases = Integer.parseInt(br.readLine());
	     while(testCases-->0){
	         int size = Integer.parseInt(br.readLine());
	         int[] arr = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	         int num = 0;
	         int i=0;
	         int total = size*size;
	         
	         while(num<total && i<size){
	             if(num >= size*(size-1)) { 
	                System.out.print(arr[num] + " ");
	                i++;
	                num = i;
	             }
	             else {
	             System.out.print(arr[num] + " ");
	             num+=size;
	             }
	         }
	         System.out.println();
	     }
	 }
	 catch (Exception e){
	     e.printStackTrace();
	 }
	 }
}

2
import math
for _ in range(int(input())):
n=math.factorial(int(input()))
print(len(str(n))-len(str(n).rstrip("0")))

3
#include<bits/stdc++.h>
using namespace std;

void bfs(bool visited[20][20],int n,int x,int y,int X,int Y,int& count){
    queue<pair<int,int>>q;
    visited[x-1][y-1]=true;
    q.push(make_pair(x,y));
    q.push(make_pair(0,0));
    while(q.size()>1){
        x=q.front().first;
        y=q.front().second;
        if(q.front().first==0 && q.front().second==0){
            q.pop();
            count++;
            q.push(make_pair(0,0));
            continue;
        }
        if(q.front().first==X && q.front().second==Y){
            return;
        }
        if(x>2 && y>1 && visited[x-3][y-2]==false){
            visited[x-3][y-2]=true;
            q.push(make_pair(x-2,y-1));
        }
        if(x>2 && y<n && visited[x-3][y]==false){
            visited[x-3][y]=true;
            q.push(make_pair(x-2,y+1));
        }
        if(x>1 && y<n-1 && visited[x-2][y+1]==false){
            visited[x-2][y+1]=true;
            q.push(make_pair(x-1,y+2));
        }
        if(x<n && y<n-1 && visited[x][y+1]==false){
            visited[x][y+1]=true;
            q.push(make_pair(x+1,y+2));
        }
        if(x<n-1 && y<n && visited[x+1][y]==false){
            visited[x+1][y]=true;
            q.push(make_pair(x+2,y+1));
        }
        if(x<n-1 && y>1 && visited[x+1][y-2]==false){
            visited[x+1][y-2]=true;
            q.push(make_pair(x+2,y-1));
        }
        if(x<n && y>2 && visited[x][y-3]==false){
            visited[x][y-3]=true;
            q.push(make_pair(x+1,y-2));
        }
        if(x>1 && y>2 && visited[x-2][y-3]==false){
            visited[x-2][y-3]=true;
            q.push(make_pair(x-1,y-2));
        }
        q.pop();
    }
}
int main()
{
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int x,y,X,Y;
        cin>>x>>y>>X>>Y;
        int count=0;
        bool visited[20][20]={false};
        bfs(visited,n,x,y,X,Y,count);
        cout<<count<<'\n';
    }
	return 0;
}

All Articles