Instead of learning solutions of LeetCode questions, understand patterns! π
π΄πππ πΊπππ πππ πΊππππ !!!!
For ex.
If input array is sorted then
- Binary search
- Two pointers
If asked for all permutations/subsets then
- Backtracking
If given a tree then
- DFS
- BFS
If given a graph then
- DFS
- BFS
If given a linked list then
- Two pointers
If recursion is banned then
- Stack
If must solve in-place then
- Swap corresponding values
- Store one or more different values in the same pointer
If asked for maximum/minimum subarray/subset/options then
- Dynamic programming
If asked for top/least K items then
- Heap
If asked for common strings then
- Map
- Trie
Else
- Map/Set for O(1) time & O(n) space
- Sort input for O(nlogn) time and O(1) space
Link : https://t.me/teamJavaHydπππ
Check out a GitHub repo by Sean Prasad if you're interested to read more about this, it's absolutely amazing!
#leetcode #placements #dsa #interview #coding #preparation #consistency #quality #programming #softwareengineering #india #competitiveprogramming #datastructures #algorithms #connections #interviewpreparation
π΄πππ πΊπππ πππ πΊππππ !!!!
For ex.
If input array is sorted then
- Binary search
- Two pointers
If asked for all permutations/subsets then
- Backtracking
If given a tree then
- DFS
- BFS
If given a graph then
- DFS
- BFS
If given a linked list then
- Two pointers
If recursion is banned then
- Stack
If must solve in-place then
- Swap corresponding values
- Store one or more different values in the same pointer
If asked for maximum/minimum subarray/subset/options then
- Dynamic programming
If asked for top/least K items then
- Heap
If asked for common strings then
- Map
- Trie
Else
- Map/Set for O(1) time & O(n) space
- Sort input for O(nlogn) time and O(1) space
Link : https://t.me/teamJavaHydπππ
Check out a GitHub repo by Sean Prasad if you're interested to read more about this, it's absolutely amazing!
#leetcode #placements #dsa #interview #coding #preparation #consistency #quality #programming #softwareengineering #india #competitiveprogramming #datastructures #algorithms #connections #interviewpreparation
public class PerfectNumber
{
public static void main(String[] args)
{
for (int number = 1; number <= 1000; number++)
{
int temp = 0;
for (int i = 1; i <= number / 2; i++)
{
if (number % i == 0)
{
temp += i;
}
}
if (temp == number)
{
System.out.println(number + " is a perfect number");
}
}
}
}
{
public static void main(String[] args)
{
for (int number = 1; number <= 1000; number++)
{
int temp = 0;
for (int i = 1; i <= number / 2; i++)
{
if (number % i == 0)
{
temp += i;
}
}
if (temp == number)
{
System.out.println(number + " is a perfect number");
}
}
}
}
π3
Forwarded from Aman Raj
π1
CloudSEK is hiring for SDE Intern - Full Stack
Passout year: 2022/ 2023/ 2024
Qualification: B.E/ B.Tech/ M.Tech/ BCA/ MCA/ MSc(cs)
Salary: βΉ 35k - 45k per month
Apply Now: https://cloudsek.com/openings/?gh_jid=4652466004&gh_src=54f8d5664us
Join us:
https://t.me/teamJavaHyd
WhatsApp: https://chat.whatsapp.com/Enb12e0I9kP6ymo2PT1ewg
Passout year: 2022/ 2023/ 2024
Qualification: B.E/ B.Tech/ M.Tech/ BCA/ MCA/ MSc(cs)
Salary: βΉ 35k - 45k per month
Apply Now: https://cloudsek.com/openings/?gh_jid=4652466004&gh_src=54f8d5664us
Join us:
https://t.me/teamJavaHyd
WhatsApp: https://chat.whatsapp.com/Enb12e0I9kP6ymo2PT1ewg
WhatsApp.com
GREAT JAVA opportunities
WhatsApp Group Invite