Saahil Rathore on LinkedIn: #leetcode #programming (2024)

Saahil Rathore

2 ⭐ Codechef (max 1563) | 7 Kyu AtCoder (max 628) | Leetcode (max 1654) | SIH '23 Finalist | AWS ML Scholar ‘23 | GenAI Buildathon Finalist | MLOPS Developer | Ex Python Developer @Bytive

  • Report this post

Leetcode Weekly Contest 402I managed to solve 3/4 , although it took a very long time to solve 3rd.Here are my appraoches: 1 -> A simple loop traversal , and just find if (hours[i]+hours[j])%24==0 and count it. 2 -> To optimize above, we can use a standard unordered map approach, where we can count if (24 - (hours[i]%24)%24 exists in the map, if yes then we can count+=mp[this value] and we add hours[i]%24 in the map. This way we can get an O(n) solution.3 -> I realized pretty quickly that this was a standard take | not take dp (as we can only take power[i] and not the remaining +-2), but implementing it took a long time. Basically,First, we create a map that stores the total damage for each unique spell. For example, if you have multiple spells that do the same damage, we add up their damages.Next, we get all the unique damage values from our map and sort them in increasing order. This makes it easier to figure out which spells can be taken without conflicting with each other.Then,We create an array dp where dp[i] will store the best possible total damage we can get by considering the first i+1 unique damage values.So,At each step i, there are two choices:Not Take: If we decide not to use the current spell damage, then our best total damage at this step will just be the same as the previous step (i.e., dp[i] = dp[i-1]).Take: If we decide to use the current spell damage, we add its total damage to the best possible total damage from previous steps that don't conflict with it.Finally, we go through each unique damage value, updating our dp state with the best possible total damage at each step, either by taking or not taking the current spell damage.#leetcode #programming

  • Saahil Rathore on LinkedIn: #leetcode #programming (2)

20

1 Comment

Like Comment

Aditya Kumar

A Cloud enthusiasts | Frontend Developer | C++ | Pre-final year student at UPES | 8x AWS Academy Certificate

3d

  • Report this comment

I agree!

Like Reply

1Reaction

To view or add a comment, sign in

More Relevant Posts

  • Saahil Rathore

    2 ⭐ Codechef (max 1563) | 7 Kyu AtCoder (max 628) | Leetcode (max 1654) | SIH '23 Finalist | AWS ML Scholar ‘23 | GenAI Buildathon Finalist | MLOPS Developer | Ex Python Developer @Bytive

    • Report this post

    Codeforces Round 952 DIV4Managed to solve 4 , although surprisingly i just couldn't optimize C , but ended up solving E instead.I think the quality of problems were great especially E , where in a 3D plane there's a box with side lengthsx,y,z with volume k and we have to return the maximum number of distinct locations a secret box can be placed that is parallel to all axes and has integer coordinates. The secret box can be placed anywhere within the 3D space, from the origin to the point (x, y, z). I think i got lucky enough that constraints were less harsher (1<=x,y,z<=2000) , so i just checked all the possible valid integer x ,y and z dimensions of cube and iterate through all possible combinations of dimensions such that their product equals k, while taking maximum.Overall i did okay, will try to upsolve the rest!#competitiveprogramming #codeforces #div4

    • Saahil Rathore on LinkedIn: #leetcode #programming (7)

    21

    2 Comments

    To view or add a comment, sign in

  • Saahil Rathore

    2 ⭐ Codechef (max 1563) | 7 Kyu AtCoder (max 628) | Leetcode (max 1654) | SIH '23 Finalist | AWS ML Scholar ‘23 | GenAI Buildathon Finalist | MLOPS Developer | Ex Python Developer @Bytive

    • Report this post

    Finally reached brown :)Secured Global Rank of 692 in AtCoder Beginner Contest 357 PS: check out 1) https://lnkd.in/gyEt_jX4 for all atcoder problems2) https://lnkd.in/gNF_KA5i a structured collection of codeforces problems#competitiveprogramming #atcoder

    • Saahil Rathore on LinkedIn: #leetcode #programming (11)

    38

    Like Comment

    To view or add a comment, sign in

  • Saahil Rathore

    2 ⭐ Codechef (max 1563) | 7 Kyu AtCoder (max 628) | Leetcode (max 1654) | SIH '23 Finalist | AWS ML Scholar ‘23 | GenAI Buildathon Finalist | MLOPS Developer | Ex Python Developer @Bytive

    • Report this post

    Codechef Starters 137 DIV3This is first time i felt the gap between second and third problem in a codechef contest 🙂! Solved the first two in 13 minutes, but i just wasn't able to crack the third past the bases cases! Here's my approaches to the first two:1 -> Just sort the vector of pairs and find the maximum value among all the pairs.2 -> Use a greedy approach. We need to maximize the sum of absolute differences, as x can vary from 1<=x<=k, for each element we put either x=1 and x=k (choosing extremes was the key) and then simply update the maximum difference throughout the array. Honestly, i could've done way better and should've scored the third , but i guess that's that for the next round :)PS: Fourth problem was absolutely brutal :0 !!#codechef #competitiveprogramming #problemsolving #div3

    • Saahil Rathore on LinkedIn: #leetcode #programming (16)

    16

    Like Comment

    To view or add a comment, sign in

  • Saahil Rathore

    2 ⭐ Codechef (max 1563) | 7 Kyu AtCoder (max 628) | Leetcode (max 1654) | SIH '23 Finalist | AWS ML Scholar ‘23 | GenAI Buildathon Finalist | MLOPS Developer | Ex Python Developer @Bytive

    • Report this post

    Codeforces Round 950 DIV 3:For some reason, today's div3 unusually felt more like div2 :0I managed to solve only two.Problem A was pretty straight forward, but B was a little bit tricky but doable. I really tried hard for C, but i realized a major flaw in my logic until the end of the contest :/I was surprised to see that E was very much similar to AtCoder Beginner Contest 332 problem D , where we needed to find the minimum operations to make matrix A equal to B by swapping adjacent rows or columns. However, i only ended up getting a TLE as my approach required checking all possible permutations of each row and column and check if any inversions exists. But yeah it wasn't very efficient :(#codeforces #competitiveprogramming #div3

    • Saahil Rathore on LinkedIn: #leetcode #programming (19)

    16

    3 Comments

    Like Comment

    To view or add a comment, sign in

  • Saahil Rathore

    2 ⭐ Codechef (max 1563) | 7 Kyu AtCoder (max 628) | Leetcode (max 1654) | SIH '23 Finalist | AWS ML Scholar ‘23 | GenAI Buildathon Finalist | MLOPS Developer | Ex Python Developer @Bytive

    • Report this post

    AtCoder Beginner Contest - 356 I managed to solve A,B,C,D with a world rank of 1581. Here are the problems and my approach to solving them:A -> Problem was to reverse a subsequence, given the length , star and end pointers. Simply use reverse(arr.begin()+l-1, arr.begin() + r );B-> Just sum up the total amounts of each nutrient consumed from all foods, and determine weather the daily requirement is met.C-> I used bit masking technique for this. That is just iterate through 0 to 2^n - 1 combination of keys and check if each mask is valid or not. I took a lot of time implementing this one, but i found other shorter approaches in other codes.D-> You are given two integers N and M, and you need to find the sum of popcounts (from k=0 to N , each taken AND with M) and then return the ans modulo a given constant. Constraints made this problem way harder to implement given N and M varied from (0 , 2^60 -1). To solve this in less than O(n^2) , just loop through each bit position up to the maximum possible bit position (which is 60) and then for each bit, create a mask and Count how many numbers in the range [0, N] have this bit set after performing the AND operation with M.Then we count the number of full blocks and the remainder part that does not form a complete block.For the remainder of the contest, i tried E but ended up getting TLE's . #atcoder #competitiveprogramming #problemsolving

    • Saahil Rathore on LinkedIn: #leetcode #programming (22)
    • Saahil Rathore on LinkedIn: #leetcode #programming (23)

    28

    5 Comments

    Like Comment

    To view or add a comment, sign in

  • Saahil Rathore

    2 ⭐ Codechef (max 1563) | 7 Kyu AtCoder (max 628) | Leetcode (max 1654) | SIH '23 Finalist | AWS ML Scholar ‘23 | GenAI Buildathon Finalist | MLOPS Developer | Ex Python Developer @Bytive

    • Report this post

    I achieved a global rank of 877 out of 25k participants in CodeChef Starters 136, finally reaching a 2 ⭐ rating after months of preparation. It feels incredibly rewarding to see the hard work pay off!#codechef #competitiveprogramming

    • Saahil Rathore on LinkedIn: #leetcode #programming (27)
    • Saahil Rathore on LinkedIn: #leetcode #programming (28)

    38

    17 Comments

    Like Comment

    To view or add a comment, sign in

  • Saahil Rathore

    2 ⭐ Codechef (max 1563) | 7 Kyu AtCoder (max 628) | Leetcode (max 1654) | SIH '23 Finalist | AWS ML Scholar ‘23 | GenAI Buildathon Finalist | MLOPS Developer | Ex Python Developer @Bytive

    • Report this post

    Today i got Global Rank of 374 out of 22k+ participants in the Codechef Starters 134 (Div4)Contest. Since the past two months, I've been grinding Codeforces DIV3 B&C's to DIV2 A&B's of recent contests, Codechef (recent weekly Starters ) , USACO Silvers , Atcoder(Beginner Contest B's&C's). To get more structure i also followed TLE Eliminators CP Sheet, solved 800, 900 and 1000 problems, the famous A20J ladders etc . However, i also fumbled my first ever Atcoder Contest (ABC 352) where i wasn't able to solve even a single problem, fumbled CF 940 DIV2 where i took a lot of time debugging problem A etc.Only after giving a codechef starters contest on one Wednesday, i noticed that the more questions i did daily, the better i got at writing brute force and write code fast. It felt like magic! After that, i started picking up DIV2 A's and was able to observe and extract the main idea very quickly, using constraints to choose which technique would be a good idea to implement etc..Then came today's contest. Solved 4 out of 7 under 20 mins. Far from what's considered to be a good number, but still the progress I'm feeling from the grind is unreal. Consistency is the key.Ps: Just read, https://lnkd.in/d-u85qEa :). My solutions: https://lnkd.in/gSJYcyXT#competitiveprogramming #consistency #codechef

    • Saahil Rathore on LinkedIn: #leetcode #programming (33)

    44

    Like Comment

    To view or add a comment, sign in

  • Saahil Rathore

    2 ⭐ Codechef (max 1563) | 7 Kyu AtCoder (max 628) | Leetcode (max 1654) | SIH '23 Finalist | AWS ML Scholar ‘23 | GenAI Buildathon Finalist | MLOPS Developer | Ex Python Developer @Bytive

    • Report this post

    Last week, I spent better part of my days studying the Windows architectural components, the Component Object Model (stay tuned for this in my next post) , windows kernel data structures etc. For a very long time, i wanted to understand how various heterogenous devices interact with the operating system. It turns out there's a software layer that handles this internally, called 'Device Drivers'. Fundamentally, device drivers take system calls and convert them into a set of instructions that the hardware can understand. This means each type of device, such as a printer, keyboard, or mouse, has its own device driver, because different hardware understands different sets of instructions.In Windows, the OS kernel and Device driver share a single virtual address space , unlike the private address spaces found in user mode. Hence, there is no protection for private read/write system memory being used by components running in kernel mode. Do you see a problem with this? Think for it yourself. Once in kernel mode, OS and device-driver code has complete access to system-space memory and can bypass Windows security to access objects. This risk was one of the reasons behind the driver-signing mechanism introduced in Windows 2000, which warns (and, if configured as such, blocks) the user if an attempt is made to add an unsigned plug-and-play driver. Simply put, all device drivers must be signed with a cryptographic key assigned by one of the major code certification authorities. The user cannot explicitly force the installation of an unsigned driver, even as an administrator.But, what if a legitimate signed driver itself had a vulnerability? On May 4, 2021, Dell Technologies releasedDell Security Advisory 2021-088which describes a privilege escalation vulnerability in their dbutil_2_3.sys driver. Reason?Do you recall the infamous Lazarus Group? Yeah that North Korean Hacker group! They were the first to discover and exploit a vulnerability in that driver!The "dbutil_2_3.sys driver "is utilized during the firmware update process and is therefore widely deployed across Dell Technologies products. It is loaded onto the system when the computer's BIOS or firmware needs to be updated. It assists in the BIOS update process and is then supposed to be unloaded after the system reboots. The driver code had a "write-what-where condition". A function allowed an attacker to write arbitrary data (the "what") to an arbitrary memory location (the "where"). It often occurs when a program fails to properly validate untrusted input before using it as a pointer (to specify the "where") or as data to write to that location (the "what"). By carefully crafting malicious input, an attacker can trick the vulnerable program into overwriting critical data structures or code in memory. Dell didn’t truly patch this issue. Their mitigation involved deletingdbutil_2_3.sysand switching to a driver namedDBUtilDrv2.sys, a driver that has existed since at least 2019.

    • Saahil Rathore on LinkedIn: #leetcode #programming (37)

    29

    3 Comments

    Like Comment

    To view or add a comment, sign in

  • Saahil Rathore

    2 ⭐ Codechef (max 1563) | 7 Kyu AtCoder (max 628) | Leetcode (max 1654) | SIH '23 Finalist | AWS ML Scholar ‘23 | GenAI Buildathon Finalist | MLOPS Developer | Ex Python Developer @Bytive

    • Report this post

    Around half a month ago i set out to solve the 19 famous introductory CSES problem set, which tackles a wide range of topics from basic math to tricky backtracking techniques!Each day I'd start with a problem , figure out what exactly does it expect and then dive deep into the underlying concepts needed to craft a solution. Some of the problems are just outright brain teasers!For instance , a question requires us to divide a sequence of integers into two sets such that their sums are equal. This seemingly innocent question kept me up for days till i figured out the bit masking method and how it can be used in framing much more quicker and efficient way of generating subsets than the standard backtracking approach.There's a famous book which really helped me out called "A Competitive Programmer's Handbook" link : https://lnkd.in/gjgT5wwXWhich has some of the most brilliant bits and techniques to solve algorithmic problems. One such example was the Grid Paths problem , which states that in a 7X7 matrix , you are given a description of a path which may also contain characters?(any direction) , and the task is to calculate the number of paths that match the description. The standard bruteforce approach takes 88,418 paths and around 76 billion recursive calls! The book guides through optimizing this overwhelming number in an efficient way, drastically reducing the computational load.Lastly, Abhishek Saini posted his solutions of the entire problem set, which were pretty useful! PS: My solutions : https://lnkd.in/gSJYcyXT#CompetitiveProgramming #CSES #ProblemSolving

    • Saahil Rathore on LinkedIn: #leetcode #programming (41)
    • Saahil Rathore on LinkedIn: #leetcode #programming (42)

    59

    2 Comments

    Like Comment

    To view or add a comment, sign in

Saahil Rathore on LinkedIn: #leetcode #programming (46)

Saahil Rathore on LinkedIn: #leetcode #programming (47)

1,445 followers

  • 70 Posts
  • 3 Articles

View Profile

Follow

More from this author

  • Essentials of vector embeddings for: Recommendation Engines Saahil Rathore 1y
  • Razorpay's defensive architecture Saahil Rathore 1y

Explore topics

  • Sales
  • Marketing
  • Business Administration
  • HR Management
  • Content Management
  • Engineering
  • Soft Skills
  • See All
Saahil Rathore on LinkedIn: #leetcode #programming (2024)

References

Top Articles
Latest Posts
Article information

Author: Neely Ledner

Last Updated:

Views: 5478

Rating: 4.1 / 5 (62 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Neely Ledner

Birthday: 1998-06-09

Address: 443 Barrows Terrace, New Jodyberg, CO 57462-5329

Phone: +2433516856029

Job: Central Legal Facilitator

Hobby: Backpacking, Jogging, Magic, Driving, Macrame, Embroidery, Foraging

Introduction: My name is Neely Ledner, I am a bright, determined, beautiful, adventurous, adventurous, spotless, calm person who loves writing and wants to share my knowledge and understanding with you.