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
public class Q24_1 {
public static void main(String[] args) {
int[] arr = {5, 6, 8, 9, 2, 4, 6, 1};
int toFind = 59;
boolean found = search(arr, toFind);
if (found)
System.out.println(toFind + " is found");
else
System.out.println(toFind + " is not found");
}
/*
* A method to search toFind in arr
* arr: the array to search
* toFind: the element to search
*/
public static boolean search(int[] arr, int toFind) {
int left = 0;
int right = arr.length - 1;
while (left <= right) {
int mid = (left + right) / 2;
if (arr[mid] == toFind) {
return true;
} else if (arr[mid] < toFind) {
left = mid + 1;
} else {
right = mid - 1;
}
}
return false;
}
}
Danaher Hiring for QA Engineer
Role: QA Enginee
Experience: Fresher
Passout year: 2022 and before
Location: Bangalore
Qualification: B.tech/BE/MCA/BCA
Salary: 4.9 - 6 LPA



Apply Now: https://jobs.danaher.com/global/en/job/DANAGLOBALR1191438EXTERNALENGLOBAL/QA-Engineer-I
public static void main(String[] args) {
int i;
int num;
StringBuilder primeNumbers = new StringBuilder();
for (i = 1; i <= 100; i++) {
int counter = 0;
for (num = i; num >= 1; num--) {
if (i % num == 0) {
counter = counter + 1;
}
}
if (counter == 2) {
primeNumbers.append(i).append(" ");
}
}
System.out.println("Prime numbers from 1 to 100 are :");
System.out.println(primeNumbers);
Thinkitive is Hiring Software Trainee Engineer
Role - Trainee software engineer
Salary - 40K - 50k per month
Passout year - 2023, 2022, 2021
Qualification - B.E /B.Tech /M.Tech /MCA /MSC /BSC /BCA /
Location: Pune, Maharashtra



Apply now:https://docs.google.com/forms/d/e/1FAIpQLSfovPgY8oRTkE1QIGcmqnzjSXYvlATDYnwrB1rPo5sLwOLvXQ/viewform
Allowing copy message from now 🙂
Make The String Great
Easy

Given a string s of lower and upper case English letters.

A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:

0 <= i <= s.length - 2
s[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.
To make the string good, you can choose two adjacent characters that make the string bad and remove them. You can keep doing this until the string becomes good.

Return the string after making it good. The answer is guaranteed to be unique under the given constraints.

Notice that an empty string is also good.



Example 1:

Input: s = "leEeetcode"
Output: "leetcode"
Explanation: In the first step, either you choose i = 1 or i = 2, both will result "leEeetcode" to be reduced to "leetcode".
Example 2:

Input: s = "abBAcC"
Output: ""
Explanation: We have many possible scenarios, and all lead to the same answer. For example:
"abBAcC" --> "aAcC" --> "cC" --> ""
"abBAcC" --> "abBA" --> "aA" --> ""
Example 3:

Input: s = "s"
Output: "s"


Constraints:

1 <= s.length <= 100
s contains only lower and upper case English letters.
👍1
One thing to note is that to judge if two adjacent characters make a pair? We do easily tell that patterns like aA, Bb, cC are pairs, but how to implement the code? We can use the their ASCII values as reference, each character has a unique ASCII value:

a = 97, A = 65
b = 98, B = 66
c = 99, C = 67 ...
z = 122, Z = 90
Thus we can tell that two characters make a pair, when and only when their ASCII values differ by 323232 (Since the sentence only contains letters of alphabet, we do not need to consider about other speical characters). Keep This is a very common trick, keep it in mind!


Algorithm
If the size of string s is smaller than 2, return s directly.
Iterate over all adjacent characters in s.
If we find a pair, remove it from s, and start over from step 2.
Otherwise, we don't need to iterate. Move to step 3.
Return s as the final good string.
We will implement the same algorithm in approach 1 using recursive method.

The trick is that each time a recursive function calls itself, it reduces the given problem into subproblems. The recursion call continues until it reaches a point where the subproblem can be solved without further recursion.

In this problem, once we find a pair that should be deleted, we are actually reducing s into a new string s' which is 2 characters smaller. Then the function calls itself for this smaller subproblem. When we can't find a pair for s, we have reached the base case where the problem can be solved by just returning s without further recursion!

Here is a brief example of the recursion approach.

img


Algorithm
Iterate over the input string s and check if a pair exists. - If we find one pair, remove it from s, and start over this step with the remaining string. - Otherwise, return s
Hey guy's hope till now every file went good getting some error while uploading files
Even for a simple small videos it is taking 2-5 hrs in uploading
Java Hyd Team
Video
Same kind of videos 😂 hope you enjoyed the explanations
👍1