Cognizant Java Coding Interview Question Answers

preview_player
Показать описание
In this video, we discussed Java Coding Interview Question which was discussed in cognizant Interview. The candidate solved the problem and got selected with CTC of 8.7 LPA.

#leetcode
#java
#interview
#javaprogramming
#javacoding
#javainterviewquestions

Complete Java Interview Preparation:
Рекомендации по теме
Комментарии
Автор

Wow Good logic dude..
I thought the same but I didn't think about substring 😁😁😁
thank you ❤️❤️❤️🔥🔥🥳🥳🥳

hemasundarkasturi
Автор

public static void divideStringInParts(){
String str = "abcdef";
int n = 2;
int parts = str.length()/n;
String prod = "";
for(int i = 0; i < str.length(); i++){
prod += str.charAt(i);
if(prod.length() == parts){
System.out.println(prod);
prod = "";
}
}
}

million
Автор

Now a days to join Cognizant it is worst i have join 2 months back nearly 2000 experience software engineer 1-6 years of experience are bench
So don't join cognizant there are destroying career

mohammedajazquadri
Автор

We can write this program in 5 lines using arrays, reverse string concept, but it will not pass more than 1 testcases 😅, damm this code deserves 8.7 absolutely

proxy
Автор

public class Practice{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
String ip = sc.nextLine();
int parts = sc.nextInt();

if(ip.length()%parts==0){
int step=ip.length()/parts;
for(int i=0; i<ip.length(); i+=step){
System.out.println(ip.substring(i, i+step));
}
}
else{
System.out.println("This string cannot be devided into "+parts+" eqal parts");
}
}
}

hemchandmovva
Автор

public class Nequalparts {

public static void main(String[] args) {

String str = "abteyfcgudiudidv";

if (str.length() % 2 == 0) {
System.out.println("div by equal parts");
String s = str.substring(0, str.length() / 2);
String y = str.substring((str.length() / 2), str.length());
System.out.println(s);
System.out.println(y);
} else {
System.out.println("Not div by equal parts");
}

}

}

anubhavraj