Java Hyd Team
746 subscribers
986 photos
39 videos
670 files
690 links
https://teamhydteam.my.canva.site/

Can visit us on our website 😊
Still working on it 😊
Download Telegram
import java.util.*;
public class _7_12_2022 {
public static void main(String[] args) {
String a = "sathyaa";
Map<Character, Integer> m = new HashMap<>();
for(int i = 0; i < a.length(); i++){
if(m.containsKey(a.charAt(i))){
m.put(a.charAt(i), m.get(a.charAt(i))+1);
} else {
m.put(a.charAt(i), 1);
}
}
System.out.println(m.toString());

/*String s = "aabbcbabadchisidb";
Map<Character, Integer> m = new HashMap<>();

for(int i = 0; i < s.length(); i++){
if(m.containsKey(s.charAt(i))){
m.put(s.charAt(i), m.get(s.charAt(i))+1);
} else {
m.put(s.charAt(i), 1);
}
}
Collection<Integer> a = m.values();
int max = Collections.max(a);
for(Character ch : m.keySet()){
if(m.get(ch)==max){
System.out.println(ch+"-"+m.get(ch));
}
}
*/
}

}
πŸ‘1
public class String_Palidrome {
//create class (class doesn't allocate space
public static void main(String[] args) {
//main method allocates space for the project in heap
String inputString = "paap";
//declaring and initializing string value
int length = inputString.length();
// initializing length with array value length
int i, begin, end, middle;
// declaring variable in int datatype
begin = 0;//initializing variable with value
end = length - 1;//initializing variable with value
middle = (begin + end) / 2;//initializing variable with value
for (i = begin; i <= middle; i++) { // for loop
if (inputString.charAt(begin) == inputString.charAt(end)) { //conditional blocks
begin++; // post increment after
end--; // post decrement after
} else { //conditional blocks
System.out.println("Not a palindrome.");//output statement
break; // breaks statement
}
}
if (i == middle + 1) { //conditional blocks
System.out.println("Palindrome."); // output statement
}
}
}
public class RemoveDuplicates {
public static void main(String[] args) {
String str = "sathya";
RemoveDuplicates obj = new RemoveDuplicates();
System.out.println(obj.removeDuplicates(str));
}
public String removeDuplicates(String s) {
char[] chars = s.toCharArray();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < chars.length; i++) {
String str = String.valueOf(chars[i]);
if (!sb.toString().contains(str)) {
sb.append(str);
}
}
return sb.toString();
}
}
import java.util.Arrays;

public class Anagram {
public static void main(String[] args) {
String str1 = "silent";
String str2 = "lister";
boolean status = true;
if (str1.length() != str2.length()) {
status = false;
} else {
char[] arr1 = str1.toLowerCase().toCharArray();
char[] arr2 = str2.toLowerCase().toCharArray();
Arrays.sort(arr1);
Arrays.sort(arr2);
status = Arrays.equals(arr1, arr2);
}
if (status) {
System.out.println("Strings are anagrams");
} else {
System.out.println("Strings are not anagrams");
}
}
}
package com.Aman;
import java.util.Scanner;
public class CompareStrings {
public static void main(String[] args) {
Scanner x = new Scanner(System.in);
System.out.println("Enter two strings");
String str1 = x.next();
String str2 = x.next();

// Compare two strings in length
int result = str1.compareTo(str2);

if(result < 0) {
System.out.println("String 1 is shorter than String 2");
} else if(result == 0) {
System.out.println("String 1 and String 2 are equal in length");
} else {
System.out.println("String 1 is longer than String 2");
}
}
}
import java.util.Scanner;
public class Armstrong {
public static void main(String[] arg) {
int a,arm=0,n,temp;
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number");
n=sc.nextInt();
temp=n;
for( ;n!=0;n/=10 )
{
a=n%10;
arm=arm+(a*a*a);
}
if(arm==temp)
System.out.println(temp+" is a armstrong number ");
else
System.out.println(temp+" is not a armstrong number ");
}
}
import java.util.Scanner;
public class FloyidsTriangle {
public static void main(String[] args){
int n,i,j,k = 1;
System.out.println("Enter the number of lines you need in the FloyidsTriangle");
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
for(i = 1; i <= n; i++) {
for(j=1;j <= i; j++){
System.out.print(" "+k++);
}
System.out.println();
}
}
}
import java.util.*;
public class Lucky_Number {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the car no:");
int num = sc.nextInt();
if (num < 1 || num > 9999) {
System.out.println(num + " is not a valid car number");
} else {
int sum = 0;
while (num > 0) {
sum += num % 10;
num /= 10;
}
if (sum % 3 == 0 sum % 5 == 0 sum % 7 == 0) {
System.out.println("Lucky Number");
} else {
System.out.println("Sorry its not my lucky number");
}
}
}
}
package com.Aman;

import java.util.Scanner;

public class kShapeAlphabets1 {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int i, j, alphabet;

System.out.print("Enter K Shape Alphabets Pattern Rows = ");
int rows = sc.nextInt();

System.out.println("Printing K Shape Alphabets Pattern");

for (i = rows - 1; i >= 0; i-- )
{
alphabet = 65;
for (j = 0 ; j <= i; j++ )
{
System.out.print((char)(alphabet + j) + " ");
}
System.out.println();
}

for (i = 1 ; i < rows; i++ )
{
alphabet = 65;
for (j = 0 ; j <= i; j++ )
{
System.out.print((char)(alphabet + j) + " ");
}
System.out.println();
}
}
}
package com.Aman;
import java.util.Scanner;
public class Staircase {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Input: n = ");
int n = sc.nextInt();
sc.close();
System.out.println("Output: " + countWays(n));
}// Function to count the number of ways to reach nth stair
static int countWays(int n){
// base case
if(n == 1)
return 1;
if (n == 2)
return 2;
return countWays(n - 1) + countWays(n - 2);
}
}
package com.Aman;
public class MadamAroraPalidrome {
/*public static void main(String[] args) {
String str = "madam arora teaches malayalam";
int startIndex = 0;
int endIndex = 0;
int count = 0;
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) != ' ') {
startIndex = i;
while (i < str.length() && str.charAt(i) != ' ') {
i++;
}
endIndex = i - 1;
String subString = str.substring(startIndex, endIndex + 1);
if (checkPalindrome(subString)) {
System.out.println(subString + " is a palindrome");
count++;
}
}
}
System.out.println("Total number of palindromes in given string is: " + count);
}
public static boolean checkPalindrome(String subString) {
int left = 0;
int right = subString.length() - 1;
while (left <= right) {
if (subString.charAt(left) != subString.charAt(right)) {
return false;
}
left++;
right--;
}
return true;
}
}*/
public static void main(String[] args) {
String str = "madam arora teaches malayalam";
String[] words = str.split(" ");

for (String a : words) {
String c = "";
for (int i = a.length() - 1; i >= 0; i--) {
c = c + a.charAt(i);
}
if (a.equals(c)) {
System.out.println(a);
}
}
}
}
every message contains 2-3 programs
package com.Aman;
import java.util.regex.Pattern;
public class Q1_A4 {
// Java Program to reverse a String
// without using inbuilt String function
// Method to reverse words of a String
static String reverseWords(String str) {
// Specifying the pattern to be searched
Pattern pattern = Pattern.compile("\\s");
// splitting String str with a pattern
// (i.e )splitting the string whenever there
// is whitespace and store in temp array.
String[] temp = pattern.split(str);
StringBuilder result = new StringBuilder();
// Iterate over the temp array and store
// the string in reverse order.
for (int i = 0; i < temp.length; i++) {
if (i == temp.length - 1)
result.insert(0, temp[i]);
else
result.insert(0, " " + temp[i]);
}
return result.toString();
}
// Driver methods to test above method
public static void main(String[] args) {
String s1 = "There is a Cat";
System.out.println(reverseWords(s1));

String s2 = " Cat is there";
System.out.println(reverseWords(s2));
}
}
package com.Aman;
public class Q1_A4_2 {
public static void main(String ... args){
String s ="there is a cat";
char []ch = s.toCharArray();
String[]A=new String[4];
int index = 0;
for(int i = 0; i<=ch.length-1;i++)
if(ch[i]!=' '){
A[index]=A[index]+ch[i];
}else
index++;
//static char[] swap(String str, int i, int j) {
// char[] ch = str.toCharArray();
//char temp = ch[i];
//ch[i] = ch[j];
//ch[j] = temp;
//return ch;
// }
// public static void main(String[] args) {
// String s = "aman";
//System.out.println(swap(s, 5, s.length() - 2));
// System.out.println(swap(s, 0, s.length() - 1));

//System.out.println(s);
}
}
Java Hyd Team pinned Β«every message contains 2-3 programsΒ»
import java.util.List;
import java.util.stream.Collectors;

import static java.util.stream.DoubleStream.of;
public class Billions{
public static void main(String[] args) {
double a ,b ;
a= System.currentTimeMillis();
List<Double> list = of(1, 1000000000).boxed().collect(Collectors.toList());
list.forEach(System.out::println);
b=System.currentTimeMillis();
System.out.println(b-a);
}
}
Try to print it and find out the time complexity for this piece
workplace WITH conflict is likely to succeed over a workplace WITHOUT conflict. Yes, you heard it right.

This is because a workplace WITHOUT conflict will have no diversity of opinion, no creativity, no new ideas, and hence no growth.

A workplace WITH conflict, on the other hand, will succeed, provided it has good conflict management.

I believe that instead of avoiding conflict, one should try to appropriately address and resolve it!

Here are some top-notch ways to manage conflict at workplaces:

1. A lot of conflicts arise out of misunderstandings, and can be prevented and resolved with clear and direct communication at every level. Be an active listener in order to prevent miscommunication.

2. Do not save the conflict resolution for later. The sooner you resolve it, the better. This is because unsolved conflict leads to bitter feelings of distrust, regret, and guilt.

3. There are a few things that would need to be ignored. Prioritize what you can and what you cannot ignore when it comes to conflict.

4. Sometimes, it is better to let others win. If you are engaging in an argument to win or to prove that the other person is wrong, the conflict will only increase, not reduce.

5. Resolve the conflict through face-to-face communication rather than e-mail or social media. It’s effective because it allows you to read the room and observe the important non-verbal cues from the person and drive the conversation in a better direction.

6. If you’ve done something wrong or inappropriate that might have contributed to the conflict, willingly or unwillingly, take accountability and apologize for your actions.

It might be impossible to eliminate workplace conflict altogether, but it is very much possible to resolve it efficiently.

Do you have a story about how you managed a conflict? Share your experience in the comments section.
πŸ‘1