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

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



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

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

الأسئلة


1. لغز عجلة السيارة
تحتوي السيارة على 4 إطارات و 1 إطار احتياطي. يمكن لكل إطار أن يسافر لمسافة أقصاها 20000 ميل قبل أن يتلف. ما هي أقصى مسافة يمكن للسيارة قطعها قبل أن تضطر إلى شراء إطار جديد؟ مسموح لك بتغيير الإطارات (باستخدام الإطارات الاحتياطية) لعدد غير محدود من المرات.

نقل
4 1 . 20000 , . , ? ( ) .

2. إتمام المهمة
رجل مهمته. يضاعف المهمة التي يقوم بها كل يوم. إذا قام الرجل بالمهمة بالكامل في 18 يومًا ، فكم عدد الأيام التي استغرقها الرجل لإكمال 25 ٪ من المهمة؟

نقل
. . 18 , , 25% ?

مهام


1. التالي مجموعة أكبر عدد الأرقام
بالنظر إلى الرقم n ، ابحث عن أصغر رقم يحتوي على نفس مجموعة الأرقام مثل n وأكبر من n. إذا كان n هو أكبر عدد ممكن مع مجموعة أرقامه ، فقم بطباعة "غير ممكن".

الإدخال:
يحتوي السطر الأول من الإدخال على عدد صحيح T يشير إلى عدد حالات الاختبار.
السطر الأول من كل حالة اختبار هو n ، n هو الرقم.

الإخراج:
اطبع العدد الأكبر من n مع نفس مجموعة الأرقام وإذا لم يكن ذلك ممكنًا ، فقم بطباعة "غير ممكن" بدون اقتباس مزدوج.

المعوقات: مثال: مخرجات المدخلات
1 ≤ T ≤ 100
1 ≤ n ≤ 100000




2
143
431



314
not possible

نقل
n, , , n, n. n — , “not possible”.

:
T, .
— n. n — .

:
, n, , , «not possible».

:
1 ≤ T ≤ 100
1 ≤ n ≤ 100000


:

2
143
431



314
not possible

2. تغيير العملة
Given a value N, find the number of ways to make change for N cents, if we have infinite supply of each of S = { S1, S2,…, Sm} valued coins. The order of coins doesn’t matter. For example, for N = 4 and S = {1,2,3}, there are four solutions: {1,1,1,1},{1,1,2},{2,2},{1,3}. So output should be 4. For N = 10 and S = {2, 5, 3, 6}, there are five solutions: {2,2,2,2,2}, {2,2,3,3}, {2,2,6}, {2,3,5} and {5,5}. So the output should be 5.

Input:
The first line contains an integer 'T' denoting the total number of test cases. In each test cases, the first line contains an integer 'M' denoting the size of array. The second line contains M space-separated integers A1, A2, ..., AN denoting the elements of the array. The third line contains an integer 'N' denoting the cents.

Output:
قم بطباعة عدد من الطرق الممكنة لإجراء تغيير لـ N سنت.

القيود: مثال: الإدخال: الإخراج: شرح: اختبار 1 : الإمكانيات على هذا النحو: {1 ، 1 ، 1 ، 1} ، {1 ، 1 ، 2} ، {1 ، 3} ، {2 ، 2}.
1 ≤ T ≤ 50
1 ≤ N ≤ 300
1 ≤ A[i] ≤ 300




2
3
1 2 3
4
4
2 5 3 6
10



4
5




نقل
N, N, S = { S1, S2, ...,., Sm}. . , N = 4 S = {1,2,3} : {1,1,1,1},{1,1,2},{2,2},{1,3}. 4. N = 10 S = {2, 5, 3, 6}, : {2,2,2,2,2}, {2,2,3,3}, {2,2,6}, {2,3,5} {5,5}. 5.

:
'T', . 'M', . M , A1, A2,..., . 'N', .

:
N.

:
1 ≤ T ≤ 50
1 ≤ N ≤ 300
1 ≤ A [i] ≤ 300


:
:

2
3
1 2 3
4
4
2 5 3 6
10


:
4
5


:
1: : {1, 1, 1, 1}, {1, 1, 2}, {1, 3}, {2, 2}.

3. دليل الهاتف
إعطاء قائمة بجهات الاتصال الموجودة في دليل الهاتف وسلسلة استعلام. المهمة هي تنفيذ استعلام البحث عن دليل الهاتف. قم بتشغيل استعلام بحث لكل بادئة p من سلسلة سلسلة الاستعلام (أي من الفهرس 1 إلى طول السلسلة) التي تطبع جميع جهات الاتصال الموصى بها والتي لها نفس بادئة الاستعلام (p) بترتيب معجمي. يرجى الرجوع إلى جزء الشرح لفهم أفضل.

ملاحظة: إذا لم يكن هناك تطابق بين الاستعلام وجهات الاتصال ، اطبع "0".

إدخال:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains three lines. First line of each test case contains N i.e., number of contacts. Second line contains space separated all the contacts in the form of string. And third line contains query string.

Output:
For each test case, print each query result in new line. If there is no match between query and contacts, print «0».

Constraints:
1<=T<=100
1<=N<=50
1<=|contact[i].length|<=50
1<=|query length|<=6


Example:
Input:

1
3
spiceit spcicecite spiiceti
spicpt


Output:
spiceit spcicecite spiiceti
spiceit spcicecite spiiceti
spiceit spiiceti
spiceit
0
0


Explanation:
By running the query on contact list, we get,
Suggestions based on "s" are:
spiceit spcicecite spiiceti
Suggestions based on "sp" are:
spiceit spcicecite spiiceti
Suggestions based on "spi" are:
spiceit spiiceti
Suggestions based on "spic" are:
spiceit
No Results Found for «spicp», So print «0».
No Results Found for «spicpt», So print «0».

, str. , . p str (. . 1 str), , , (p) . , .

: , «0».

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

:
. , «0».

:
1<=T<=100
1<=N<=50
1<=|contact[i].length|<=50
1<=| |<=6


:
:

1
3
spiceit spcicecite spiiceti
spicpt


:
spiceit spcicecite spiiceti
spiceit spcicecite spiiceti
spiceit spiiceti
spiceit
0
0


:
, ,
"s", :
spiceit spcicecite spiiceti
"sp", :
spiceit spcicecite spiiceti
"spi", :
spiceit spiiceti
"spic", :
spiceit
«spicp» , «0».
«spicpt» , «0».



1
: 25000 .
: 4 , . . 5000, 5000 .

A, B, C D, — S.

5000 : A S. (A, B, C, D, S): 15000, 15000, 15000, 15000, 20000.
10000 : A B S. (A, B, C, D, S): 15000, 10000, 10000, 10000, 15000.
15000 : B C S. (A, B, C, D, S): 10000, 10000, 5000, 5000, 10000.
20000 : C D S. (A, B, C, D, S): 5000, 5000, 5000, 0, 5000.
25000 : .

2
: 16
100% = 18
,
50% = 17
25% = 16 .

1
import java.io.*;

class GFG {
	public static void main (String[] args) {
		//code
		GFG gfg = new GFG();
		int testCases, n, i;
		String a;
		char[] c;
		Scanner sc = new Scanner(System.in);
		
		testCases = sc.nextInt();
		
		for(int t = 0; t < testCases; t++)
		{
		    a = sc.next();
		    c = a.toCharArray();
		    i = a.length() - 1;
		    
		    while(i > 0)
		    {
		        if(c[i-1] >= c[i])
		        {
		            i--;
		        }
		        else
		        {
		            break;
		        }
		    }
		    
		    if(i == 0)
		    {
		        System.out.println("not possible");
		    }
		    else
		    {
		        i--;
		        
		    
		        int j = i + 1;
		    
		        for(int k = i + 2; k < a.length(); k++)
		        {
		            if(c[k] > c[i])
		            {
		                j = k;
		            }
		        }
		        
		        char v = c[i];
		        c[i] = c[j];
		        c[j] = v;
		        i++;
		        
		        Arrays.sort(c, i, c.length);
		    
		    
		    
		    for(int k = 0; k < a.length(); k++)
		    {
		        System.out.print(c[k]);
		    }
		    System.out.println();		
		        
		    }
		}
		
	}
}

2
for _ in range(int(input())):
    n,ar,m=int(input()),list(map(int,input().split())),int(input())
    dp=[0]*(m+1)
    dp[0]=1
    for i in range(n):
        for j in range(ar[i],m+1):
            dp[j]+=dp[j-ar[i]]
    print(dp[m]) 

3
, TRIE.
, 0 1..n
.
import java.util.*;
import java.lang.*;
import java.io.*;
class trie
{
  HashMap<Character,trie> child;;
  boolean isEnd;
  trie()
  {
    isEnd=false;
    child=new HashMap<>();
  }
  void add(String a,trie root)
  {
  trie cur=root;
  for (int i=0;i<a.length() ;++i ) {
    if(cur.child.containsKey(a.charAt(i)))
    cur=cur.child.get(a.charAt(i));
    else
    {cur.child.put(a.charAt(i),new trie());
      cur=cur.child.get(a.charAt(i));
    }
  }
  cur.isEnd=true;
  }
   void search(String a,trie root)
   {
     trie cur=root;
     for (int i=0; i<a.length();++i ) {
       char t=a.charAt(i);
       trie node=cur.child.get(t);
       if(node==null)
       {System.out.print("0");
     return;}

     cur=node;
     }
     print(cur,a);
   }
   void print(trie root,String prefix)
   {
       if(root.isEnd)
       {System.out.print(prefix+" ");
       }
     for(char i='a';i<='z';++i)
     {
       trie node=root.child.get(i);
       
       if(node!=null)
       print(node,prefix+i);
     }
   }
}
class phoneDict
 {
  static trie root;
  public static void fn(String a[],int n,String q)
  {
    for (String t :a ) {
      root.add(t,root);
    }
    for(int i=1;i<=q.length();++i)
    {root.search(q.substring(0,i),root);
      System.out.println();
    }
  }
 public static void main (String[] args)
  {
 Scanner ab=new Scanner(System.in);
 int t=ab.nextInt();
 while(t-->0)
 {
     root=new trie();
     int n=ab.nextInt();
     String arr[]=new String[n];
     for(int i=0;i<n;++i)
     arr[i]=ab.next();
      fn(arr,n,ab.next());
     //System.out.println();
 }
  }
}

All Articles