< 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/โฆ
Forwarded from GDG On Campus AASTU (๐๐๐๐๐ ๐)
Are you curious about tech and looking for ways to connect with like-minded individuals?๐ง
Join us for an exciting Info Session organized by Google Developer Groups (GDG) On Campus - AASTU in collaboration with AASTU Software Engineering Association (SEA)!
Whatโs in it for you?๐
Get an introduction to Google Developer Groups (GDG) and AASTU SEA, and discover how joining these communities can enhance your tech journey.
Meet the GDG and SEA Campus Leads and get insights into upcoming events, workshops, and more.
Explore how GDG and SEA can support your passion for tech, from beginner to advanced skills.
Network with other tech enthusiasts and make new friends!
Event Details๐
Who should attend?๐
Everyone is welcome! Whether you're a complete beginner, an aspiring developer, or already deep into coding, this session is for you. No prior experience is required, just a passion for learning and connecting!
Follow Us๐
Stay updated by following our social media for more details and updates. Connect with us on:
Telegram
Newsletter
#GDGAASTU #AASTUSEA #InfoSession #TechForAll #LearnAndConnect #AASTUEvents #GDGOnCampus #NetworkAndGrow
Please open Telegram to view this post
VIEW IN TELEGRAM
๐ Quiz Time! ๐
Weโre kicking off our Exam Prep Quiz for Computer Organization & Architecture! ๐ฅ Get ready for a fun round of questions to test your knowledge! ๐ง Click your answer below and letโs see whoโs got this! ๐ช๐
๐๐ @AceCoding Presents! ๐๐
๐ Warm-Up Time!
๐ Letโs get started with some easy questions to warm up for the Computer Organization & Architecture exam! ๐ง Donโt stress, weโll take it slow to get the ball rolling! ๐ช Answer the first question below and letโs dive in! ๐
๐ Letโs get started with some easy questions to warm up for the Computer Organization & Architecture exam! ๐ง Donโt stress, weโll take it slow to get the ball rolling! ๐ช Answer the first question below and letโs dive in! ๐
Forwarded from โค
1. ๐ First Question: What is Assembly Language?
Anonymous Quiz
95%
A) Machine-dependent and close to hardware
0%
B) High-level and easy to read
5%
C) Used only for web development
0%
D) A version of Python
Forwarded from โค
2. ๐ง True or False: A register in the CPU is a small storage location that holds data temporarily.
Anonymous Quiz
71%
A) True
29%
B) False
Forwarded from โค
3. ๐ป What type of register is used to store the address of the next instruction to execute?
Anonymous Quiz
21%
A) Data Register (DR)
66%
B) Program Counter (PC)
10%
C) Base Register (BR)
3%
D) Status Register (SR)
Forwarded from โค
4. ๐ Which of the following is NOT a general-purpose register in the x86 architecture?
Anonymous Quiz
8%
A) AX
31%
B) BX
50%
C) CS
12%
D) DX
Forwarded from โค
5. ๐ True or False: In Assembly language, you can move data directly from one memory location to another without using a register.
Anonymous Quiz
19%
A) True
81%
B) False
Forwarded from โค
6. ๐ง What is the primary role of the Stack Pointer (SP) register?
Anonymous Quiz
33%
A) Holds the return address of function calls
67%
B) Points to the top of the stack in memory
0%
C) Holds data for calculations
0%
D) Stores flags for arithmetic operations
Forwarded from โค
7. โ๏ธ Which of the following instructions is used to load a value from a memory location into a register?
Anonymous Quiz
53%
A) MOV
11%
B) ADD
37%
C) PUSH
0%
D) JUMP