CODING SOLUTIONS | IBM | AMAZON CODING SOLUTIONS
Kanalga Telegram’da o‘tish
8 815
Obunachilar
Ma'lumot yo'q24 soatlar
-207 kun
-11730 kun
Postlar arxiv
class Patient:
def init(self,id,name,age,doctorName,billAmount):
self.id=id
self.name=name
self.age=age
self.doctorName=doctorName
self.billAmount=billAmount
class Doctor:
def init(self,hospitalName,PatientList):
self.hospitalName=hospitalName
self.PatientList=PatientList
def findPatientWithMaximumAge(self):
result1=max(self.PatientList,key=lambda x:x.age)
return result1
def sortPatientByBillAmount(self):
result2=sorted(self.PatientList,key=lambda x:x.billAmount)
return result2
PatientList=[]
count=int(input())
for i in range (count):
id=input()
name=input()
age=int(input())
doctorName=input()
billAmount=float(input())
p=Patient(id,name,age,doctorName,billAmount)
PatientList.append(p)
f=Doctor("ANRC",PatientList)
r1=f.findPatientWithMaximumAge()
if(r1==None):
print("No Data Found")
else:
print(r1.id)
print(r1.name)
print(r1.age)
print(r1.doctorName)
print(r1.billAmount)
r2=f.sortPatientByBillAmount()
if(r2==None):
print("No Data Found")
else:
for i in r2:
print(i.billAmount)
✅Telegram : https://t.me/coding_solutions_all
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) throws Exception{
//Enter your Code here
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
Player[] players = new Player[n];
for(int i=0;i<players.length;i++) {
Player temp=new Player();
temp.id=sc.nextInt();
temp.matchesPlayed=sc.nextInt();
temp.totalRuns=sc.nextInt();
sc.nextLine();
temp.name=sc.nextLine();
temp.team=sc.nextLine();
players[i]=temp;
}
int Id=sc.nextInt();
Player p=findPlayerWithMinimumMatchesPlayed(players);
if (p != null) {
System.out.println("id-"+p.id);
System.out.println("matchesPlayed-"+p.matchesPlayed);
System.out.println("totalRuns-"+p.totalRuns);
System.out.println("name-"+p.name);
System.out.println("team-"+p.team);
}
else{
System.out.println("No Player found with mentioned attribute");
}
Player p2=searchPlayerById(players,Id);
if (p2 != null) {
System.out.println("id-"+p2.id);
System.out.println("matchesPlayed-"+p2.matchesPlayed);
System.out.println("totalRuns-"+p2.totalRuns);
System.out.println("name-"+p2.name);
System.out.println("team-"+p2.team);
}
else{
System.out.println("No Player found with mentioned attribute");
}
}
public static Player findPlayerWithMinimumMatchesPlayed(Player[] players)
{
//Enter your Code here
Player minPlayed=players[0];
for(int i=0; i<players.length;i++){
if (players[i].matchesPlayed<minPlayed.matchesPlayed){
minPlayed=players[i];
}
}
return minPlayed;
}
public static Player searchPlayerById(Player[] players, int id)
{
for(int i=0;i<players.length;i++) {
if(players[i].id==id) {
return players[i];
}
}
return null;
}
}
class Player
{
int id;
int matchesPlayed;
int totalRuns;
String name;
String team;
public Player() {
this.id=0;
this.matchesPlayed=0;
this.totalRuns=0;
this.name="";
this.team="";
}
}
✅Telegram : https://t.me/coding_solutions_all
awk '{ln=length}
ln>max{delete result;max=ln}
ln==max{result[NR]=$0}
END{for(i in result)
print result[i]}'
7th June PRA Discussion Group
https://t.me/tcs_infosys
https://t.me/tcs_infosys
https://t.me/tcs_infosys
🤡FREE PRA ANSWERS WILL BE PROVIDED HERE ON 7TH JUNE🤡
867. Transpose Matrix
Given a 2D integer array matrix, return the transpose of matrix.
The transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices.
Example 1:
Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
Output: [[1,4,7],[2,5,8],[3,6,9]]
Example 2:
Input: matrix = [[1,2,3],[4,5,6]]
Output: [[1,4],[2,5],[3,6]]
class Solution {
public:
vector<vector<int>> transpose(vector<vector<int>>& matrix) {
vector<vector<int>> ans;
for(int i=0;i<matrix[0].size();i++)
{
vector<int>temp;
for(int j=0;j<matrix.size();j++)
{
temp.push_back(matrix[j][i]);
}
ans.push_back(temp);
}
return ans;
}
};
// TC O(N*M)
// SC O(N*M)
✅Telegram :https://t.me/coding_solutions_all
Questions. Answer
1-flume agent - test/flume/data
2. Flume flows - reduce load sink connect to hdfs
3.Mango shell- javascript
4. Channel capacity in hdfssink conf- 100000
5. Function for Wider RDD- join()
6. Not Command options for secondary namenode- Generic options
7.Spark disk per node- 4 to 8
8. Flume state --- true
9.sort ageDS--- order by
10. RDd ,map() and Filter- Narrow transformation
11. DATA FRAME- show()
✅Telegram :https://t.me/coding_solutions_all
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
class Fabric {
int id;
String name;
int availableStock;
double price;
Fabric(int id, String name, int availableStock, double price) {
this.id = id;
this.name = name;
this.availableStock = availableStock;
this.price = price;
}
public void setId(int id) {
this.id = id;
}
public void setname(String name) {
this.name = name;
}
public void setavaialbleStock(int availableStock) {
this.availableStock = availableStock;
}
public void setprice(double price) {
this.price = price;
}
}
public class Solution {
public static void main(String args[]){
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n;
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
sc.nextLine();
Fabric[] f = new Fabric[n];
for (int i = 0; i < n; i++) {
int id = sc.nextInt();
sc.nextLine();
String name = sc.nextLine();
int availableStock = sc.nextInt();
sc.nextLine();
double price = sc.nextDouble();
sc.nextLine();
f[i] = new Fabric(id, name, availableStock, price);
}
String nm = sc.nextLine();
Fabric fm = findFabricWithMaximumPrice(f);
if (fm != null) {
System.out.println("id-" + fm.id);
System.out.println("name-" + fm.name);
System.out.println("availableStock-" + fm.availableStock);
System.out.println("price-" + fm.price);
} else {
System.out.println("No Fabric found with mentioned attribute.");
}
Fabric fn = searchFabricByName(f, nm);
if (fn != null) {
System.out.println("id-" + fn.id);
System.out.println("name-" + fn.name);
System.out.println("availableStock-" + fn.availableStock);
System.out.println("price-" + fn.price);
} else {
System.out.println("No Fabric found with mentioned attribute.");
}
}
public static Fabric findFabricWithMaximumPrice(Fabric[] f) {
if(f.length==0){
return null;
}
int l = f.length;
double mp = f[0].price;
Fabric ans = null;
for (int i = 0; i < l; i++) {
if (f[i].price >= mp) {
ans = f[i];
}
}
return ans;
}
public static Fabric searchFabricByName(Fabric[] f, String nm) {
int l = f.length;
for (int i = 0; i < l; i++) {
if (nm.equals(f[i].name)) {
return f[i];
}
}
return null;
}
}
✅Telegram :https://t.me/coding_solutions_all
Just give double underscores before and after init 1st and 7th line ☝
class Toy:
def init(self,id,name,quantity):
self.id=id
self.name=name
self.quantity=quantity
class ToyStore:
def init(self,toyStoreName,toyList):
self.toyStoreName=toyStoreName
self.toyList=toyList
def findToyWithMaximumQuality(self):
if len(self.toyList)==0:
return None
else:
max_obj = max(self.toyList, key=lambda x:x.quantity)
return max_obj
def sortToyById(self):
if len(self.toyList)==0:
return None
else:
sorted_list = sorted(self.toyList, key=lambda x:x.id)
return sorted_list
n = int(input())
toyList = []
for i in range(n):
id = int(input())
name = (input())
quantity = float(input())
s = Toy(id,name,quantity)
toyList.append(s)
d = ToyStore("Dep1", toyList)
o1 = d.findToyWithMaximumQuality()
if o1==None:
print("No Data Found")
else:
print(o1.id)
print(o1.name)
print(o1.quantity)
o2 = d.sortToyById()
if o2==None:
print("No Data Found")
else:
for o in o2:
print(o.id)
✅Telegram :https://t.me/coding_solutions_all
Python Unix :
awk 'BEGIN{FS="@";}
{
if($4=="Yes" && $2>4999)
{
print $0;
}
}END{
}'
✅Telegram :https://t.me/coding_solutions_all
Working
Python Unix :
awk 'BEGIN{FS=","} {print($2,$4)}END{}'
✅Telegram :https://t.me/coding_solutions_all
🤡TCS PRA2 Python June 2nd
1)c
2)D
3)C
4)C (who)
5)A
6)D
7)A
8)C
9)D
10)A
11)D
12)B
13)all of these
14)C
15)True
16)B
17)B
18)Client
19)C ( to add interactivity)
20)C
21)A(44)
22)False
23)id
24)B
25)A
26)A
27)C
28)A
29)B
30)A
✅Telegram :https://t.me/coding_solutions_all
🤡TCS PRA 2 Python June 2nd
1)c
2)D
3)
4)C (who)
5)A
6)D
7)A
8)
9)D
10
11)D
12)B
13)
14)C
15)True
16)B
17)B
18)Client
19)C ( to add interactivity)
20)C
21)A(44)
22)
23)id
24)B
25)A
26)A
27)C
28)A
29)B
30)A
✅Telegram :https://t.me/coding_solutions_all
Share ✅
🤡TCS PRA 2 JAVA JUNE 2nd
1.b
2.55 D
3.True
4.False
5.15 B
6.-128 to 127 C
7. a
8. True
9.
10.TRUE
11. 1010
12.C
13.B
14. Cyan A
15.yellow C
16.A
17.C,D
18.True
19. True
20.
21.HEADING
22.C
23.B
24.True
25. True
26.-t
27.all
28.C
29.cat>> A
30.a,b,c
✅Telegram :https://t.me/coding_solutions_all
6.ISEmirp
public static int countEmirp(int[] input1, int input2) {
int count = 0;
int res;
for(int i = 0; i < input1.length; i++) {
res = reverse(input1[i]);
if(res != input1[i]) {
if(isPrime(res) == true)
count++;
}
}
return count;
}
public static int reverse(int x)
{
int rev = 0;
while (x > 0)
{
rev = (rev * 10) + x % 10;
x = x / 10;
}
return rev;
}
public static boolean isPrime(int n)
{
// Corner case
if (n <= 1)
return false;
// Check from 2 to n-1
for (int i = 2; i < n; i++)
if (n % i == 0)
return false;
return true;
}
✅Telegram :https://t.me/coding_solutions_all
