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 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
Don’t Just LeetCode, Follow the Coding Patterns Instead.πŸŸ’βœ”οΈπŸ’―

Everyone who is preparing DSA is well known about the platform called LeetCode.

But the main problem is - It has a massive amount of questions to practice around 2463 till date.

And if you have limited time for preparation, it would be difficult to solve these many problems.

Not because you will not be able to solve it, but because it needs a lot of time to solve and no one really likes spending that much time.

Bhaiya, but solution kya hai iska ?

Simple – Try to see Coding Problem Patterns

People used to be in the same loop by solving questions of the same data structure, due to which they might left grasping the command on a lot of important Data Structure and Algorithms.

I have gathered around 20 of these Coding problem patterns that I believe can help anyone learn these beautiful algorithmic techniques and make a real difference in the coding interviews.

1) Sliding Window
2) Islands (Matrix Traversal)
3) Two Pointers
4) Fast & Slow Pointers
5) Merge Intervals
6) Cyclic Sort
7) In-place Reversal of a LinkedList
8) Tree Breadth-First Search
9) Tree Depth First Search
10) Two Heaps
11) Subsets
12) Modified Binary Search
13) Bitwise XOR
14) Top β€˜K’ Elements
15) K-way Merge
16) Topological Sort
17) 0/1 Knapsack
18) Fibonacci Numbers
19) Palindromic Subsequence
20) Longest Common Substring