π¨π Attention DSA Gurus and Pros! ππ¨
If youβre a master at DSA or looking to sharpen your skills, check out these two MONSTER books! πͺπΉ
You may already know them, but for those who donβt, let me introduce you! These books are packed with in-depth knowledge and details. πβ¨
Quick tip: Donβt feel like you have to read every pageβuse them to brush up on specific topics! Thereβs no need to finish them cover to cover, or youβll just end up with too much info to remember. π§ π¨
Dive in and get ready to level up! ππ₯
ππ @AceCoding Presents! ππ GET THE BOOKSπ
If youβre a master at DSA or looking to sharpen your skills, check out these two MONSTER books! πͺπΉ
You may already know them, but for those who donβt, let me introduce you! These books are packed with in-depth knowledge and details. πβ¨
Quick tip: Donβt feel like you have to read every pageβuse them to brush up on specific topics! Thereβs no need to finish them cover to cover, or youβll just end up with too much info to remember. π§ π¨
Dive in and get ready to level up! ππ₯
ππ @AceCoding Presents! ππ GET THE BOOKSπ
π₯3πΏ1
ππ€ Stay Tuned! π€π
Weβre cooking up a storm with exciting news, questions, and super useful resources just for you! π₯π
π΄Donβt keep it to yourself share the loveπ»!
π’Spread the word π to your friends and anyone who could use a boost in their coding journey. Letβs grow together! π
Weβre cooking up a storm with exciting news, questions, and super useful resources just for you! π₯π
π΄Donβt keep it to yourself share the loveπ»!
π’Spread the word π to your friends and anyone who could use a boost in their coding journey. Letβs grow together! π
π1π1
Audio
π DSA Intro Audio π§
Boost your learning by engaging multiple senses! Weβre excited to share a high-quality audio introduction to Data Structures & Algorithms. Perfect for listening anytime, anywhere.
π‘ Sources:
β¨ A2SV notes
π Grokking Algorithms
π Cracking the Coding Interview
π Class Notes (Ch. 1 & 2)
π Codeforces & HackerRank
π» GeeksForGeeks
π Dive in and make studying more immersive and effective! π
ππ @AceCoding Presents! ππ
Boost your learning by engaging multiple senses! Weβre excited to share a high-quality audio introduction to Data Structures & Algorithms. Perfect for listening anytime, anywhere.
π‘ Sources:
β¨ A2SV notes
π Grokking Algorithms
π Cracking the Coding Interview
π Class Notes (Ch. 1 & 2)
π Codeforces & HackerRank
π» GeeksForGeeks
π Dive in and make studying more immersive and effective! π
ππ @AceCoding Presents! ππ
π1
< Ace Coding /> π
https://www.hackerrank.com/challenges/insertionsort1/problem
β
First try the question by yourself and then try to compare your solution with mine:
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'insertionSort1' function below.
#
# The function accepts following parameters:
# 1. INTEGER n
# 2. INTEGER_ARRAY arr
#
def insertionSort1(n, arr):
# Write your code here
for i in range(n):
j = i
curr = arr[i]
if curr < arr[j-1]:
while j > 0 and curr < arr[j-1]:
arr[j]= arr[j-1]
j-=1
print(*arr)
if j != i:
arr[j] = curr
print(*arr)
if __name__ == '__main__':
n = int(input().strip())
arr = list(map(int, input().rstrip().split()))
insertionSort1(n, arr)
π2
β
π» Here is a C++ implementation for the above question.
#include <bits/stdc++.h>
using namespace std;
string ltrim(const string &);
string rtrim(const string &);
vector<string> split(const string &);
/*
* Complete the 'insertionSort1' function below.
*
* The function accepts following parameters:
* 1. INTEGER n
* 2. INTEGER_ARRAY arr
*/
void insertionSort1(int n, vector<int> arr) {
for (int i = 1; i < n; i++) {
int curr = arr[i];
int j = i;
if (curr < arr[j - 1]) {
while (j > 0 && curr < arr[j - 1]) {
arr[j] = arr[j - 1];
j--;
for (int k = 0; k < n; k++) {
cout << arr[k] << " ";
}
cout << endl;
}
if (j != i) {
arr[j] = curr;
for (int k = 0; k < n; k++) {
cout << arr[k] << " ";
}
cout << endl;
}
}
}
}
int main()
{
string n_temp;
getline(cin, n_temp);
int n = stoi(ltrim(rtrim(n_temp)));
string arr_temp_temp;
getline(cin, arr_temp_temp);
vector<string> arr_temp = split(rtrim(arr_temp_temp));
vector<int> arr(n);
for (int i = 0; i < n; i++) {
int arr_item = stoi(arr_temp[i]);
arr[i] = arr_item;
}
insertionSort1(n, arr);
return 0;
}
string ltrim(const string &str) {
string s(str);
s.erase(
s.begin(),
find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace)))
);
return s;
}
string rtrim(const string &str) {
string s(str);
s.erase(
find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(),
s.end()
);
return s;
}
vector<string> split(const string &str) {
vector<string> tokens;
string::size_type start = 0;
string::size_type end = 0;
while ((end = str.find(" ", start)) != string::npos) {
tokens.push_back(str.substr(start, end - start));
start = end + 1;
}
tokens.push_back(str.substr(start));
return tokens;
}
π1
< Ace Coding /> π
β
π» Here is a C++ implementation for the above question. #include <bits/stdc++.h> using namespace std; string ltrim(const string &); string rtrim(const string &); vector<string> split(const string &); /* * Complete the 'insertionSort1' function below. β¦
Don't panic tho when you see the c++ version is a lot, you are asked to implement the insertion sort function only the rest are given by default.
< Ace Coding /> π
https://www.hackerrank.com/challenges/countingsort1/problem
π» Solution:
def countingSort(arr):
# Write your code here
count = [0]*100
for n in arr:
count[n] += 1
return count
β
C++ version:
vector<int> countingSort(vector<int> arr) {
vector<int> count(100); // arrays connot be returned so make sure to use vectors
for (int i = 0; i < arr.size(); i++){
// for vectors use size() method the length() method works for strings only
count[arr[i]]++;
}
return count;
}
< Ace Coding /> π
β
C++ version: vector<int> countingSort(vector<int> arr) { vector<int> count(100); // arrays connot be returned so make sure to use vectors for (int i = 0; i < arr.size(); i++){ // for vectors use size() method the length() method works for stringsβ¦
vector<int> countingSort(vector<int> arr) {
vector<int> count(100);
for (int i = 0; i < arr.size(); i++){
count[arr[i]]++;
}
return count;
}π¨βπ» This question is flagged as EASY on LeetCode, but trust me, itβs the kind of 'easy' that makes you question your life choices. youβll definitely give it a hard stare. π€¨
Acceptance Rate = 62%
https://leetcode.com/problems/sort-even-and-odd-indices-independently/description/
#LeetCode #DSA #HardEasy
Acceptance Rate = 62%
π¬ If you're new to leetcode don't bother trying to solve it I will share more feasible questions for beginners.
https://leetcode.com/problems/sort-even-and-odd-indices-independently/description/
#LeetCode #DSA #HardEasy
LeetCode
Sort Even and Odd Indices Independently - LeetCode
Can you solve this real interview question? Sort Even and Odd Indices Independently - You are given a 0-indexed integer array nums. Rearrange the values of nums according to the following rules:
1. Sort the values at odd indices of nums in non-increasingβ¦
1. Sort the values at odd indices of nums in non-increasingβ¦
π₯ Solution:
class Solution:
def sortEvenOdd(self, nums: List[int]) -> List[int]:
n = len(nums)
even_indexes = [nums[i] for i in range(0, n, 2)]
# range(start, end, step)
odd_indexes = [nums[i] for i in range(1, n, 2)]
even_indexes.sort()
odd_indexes.sort(reverse=True)
even_ptr = odd_ptr = 0
res = []
for i in range(n):
if i % 2 == 0:
res.append(even_indexes[even_ptr])
even_ptr += 1
else:
res.append(odd_indexes[odd_ptr])
odd_ptr += 1
return res
β
Hereβs where things get a bit off . You might already know this technique, but for those who donβt, Iβll break it down. Just ask.
π¬ This is a beautiful and super helpful piece of Python syntax sugar. The Pythonistas β¨π out there might already know it, but for everyone else, for your long-term success in DSA, leetcode or coding interviews learn Python ASAP π»π
π¬ This is a beautiful and super helpful piece of Python syntax sugar. The Pythonistas β¨π out there might already know it, but for everyone else, for your long-term success in DSA, leetcode or coding interviews learn Python ASAP π»π
class Solution:
def sortEvenOdd(self, nums: List[int]) -> List[int]:
nums[::2] = sorted(nums[::2])
nums[1::2] = sorted(nums[1::2], reverse=True)
return nums
π₯1
π» C++ version:
// #include <bits/std++.h>
// using namespace std;
// If you are running it locally make sure to include the above in your code
class Solution {
public:
vector<int> sortEvenOdd(vector<int>& nums) {
int n = nums.size();
vector<int> even_indexes;
vector<int> odd_indexes;
for (int i = 0; i < n; i += 2) {
even_indexes.push_back(nums[i]);
}
for (int i = 1; i < n; i += 2) {
odd_indexes.push_back(nums[i]);
}
sort(even_indexes.begin(), even_indexes.end());
sort(odd_indexes.rbegin(), odd_indexes.rend());
int even_ptr = 0, odd_ptr = 0;
vector<int> res(n);
for (int i = 0; i < n; ++i) {
if (i % 2 == 0) {
res[i] = even_indexes[even_ptr++];
} else {
res[i] = odd_indexes[odd_ptr++];
}
}
return res;
}
};
π4
π¨βπ» SYSTEM DESIGN (SD), SYSTEM ANALYSIS AND DESIGN (SAD) - π NeetCode has absolutely nailed it! Every detail is explained with such clarity π₯ Check it out!
https://youtu.be/i53Gi_K3o7I?si=l8Pvp_dhjkXiVoSq
https://youtu.be/i53Gi_K3o7I?si=l8Pvp_dhjkXiVoSq
YouTube
20 System Design Concepts Explained in 10 Minutes
π https://neetcode.io/ - A better way to prepare for coding interviews!
A brief overview of 20 system design concepts for system design interviews.
Checkout my second Channel: @NeetCodeIO
π§βπΌ LinkedIn: https://www.linkedin.com/in/navdeep-singh-3aaa14161/β¦
A brief overview of 20 system design concepts for system design interviews.
Checkout my second Channel: @NeetCodeIO
π§βπΌ LinkedIn: https://www.linkedin.com/in/navdeep-singh-3aaa14161/β¦