Tumgik
#leetcode problems
analyticspursuit · 2 years
Text
Python Interview Question: Moving Zeroes
In this video, we're going to be looking at a Python interview question called "Moving Zeroes." This question is a great way to test your knowledge of Python and critical thinking skills. If you're looking for Python interview questions to practice on, be sure to check out our video! We'll show you how to solve the problem and test your knowledge of Python.
As always, if you have any questions or feedback, feel free to let us know in the comments below!
0 notes
herawell · 5 months
Text
.
3 notes · View notes
straightlightyagami · 9 months
Text
sitting in my room living the gamer lifestyle (doing leetcode problems)
3 notes · View notes
tunder · 2 years
Text
I started doing leetcode. Todays the second day i feel incredibly stupid. Is this supposed to get me a job or destroy my confidence? I’m not sure
8 notes · View notes
tototavros · 2 years
Text
who has two thumbs and can't tell the difference between a row and a column
9 notes · View notes
freelancingdiary · 7 months
Text
242. Valid Anagram
New Post has been published on https://freelancingdiary.com/242-valid-anagram/
242. Valid Anagram
Problem
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
Example 1:Input: s = “anagram”, t = “nagaram” Output: true
Example 2:Input: s = “rat”, t = “car” Output: false
Constraints:
1 <= s.length, t.length <= 5 * 104
s and t consist of lowercase English letters.
Follow up: What if the inputs contain Unicode characters? How would you adapt your solution to such a case?
Solution
First attempt : (Non optimized)
/** * @param string s * @param string t * @return boolean */ var isAnagram = function(s, t) const sset = s.split(""); const tset = t.split(""); if(s.length == t.length) for(let i = 0 ; i < sset.length; i++) let value =sset[i]; if(tset.includes(value)) let index = tset.indexOf(value); tset.splice(index,1) else return false; else return false; return true ;
After giving it a second attempt I tried optimizing it further and here is what I have done so far :
/** * @param string s * @param string t * @return boolean */ var isAnagram = function(s, t) let ss = s.split(""); let tt = t.split(""); const dict = if(s.length == t.length) for(let i = 0 ; i < ss.length; i++) if(dict[ss[i]]) dict[ss[i]]++; else dict[ss[i]] = 1; for(let y = 0 ; y < tt.length; y++) if(dict[tt[y]]) dict[tt[y]]--; else return false; else return false; return true ;
0 notes
excludedmiddle · 2 years
Text
Another day, another leetcode contest with a stupid string problem I can't solve. Solution to this one felt like it probably wasn't bad, too.
I have a Python solution that should be within bounds, but when testing on large results, it ranged from 4 seconds to TLE (over 10).
Increasingly finding competing in Python very disheartening. Think I might take a break from leetcode contests for the moment and just focus on the ones where I can compete in Rust. Eventually I'll come back to Leetcode and make it to top 1000, but I think competing and practicing on here at this current stage seems like it's hurting more than it's helping.
0 notes
phantomrose96 · 7 months
Note
Hey not to go all "tumblr is a professional networking site" on you, but how did you get to work for Microsoft??? I'm a recent grad and I'm being eviscerated out here trying to apply for industry jobs & your liveblogging about your job sounds so much less evil than Data Entry IT Job #43461
This place is basically LinkedIn to me.
I'm gonna start by saying I am so so very sorry you're a recent grad in the year 2024... Tech job market is complete ass right now and it is not just you. I started fulltime in 2018, and for 2018-2022 it was completely normal to see a yearly outflow of people hopping to new jobs and a yearly inflow of new hires. Then sometime around late-spring/early-summer of 2022 Wallstreet sneezed the word "recession" and every tech company simultaneously shit themselves.
Tons of layoffs happened, meaning you're competing not just with new grads but with thousands of experienced workers who got shafted by their company. My org squeaked by with a small amount of layoffs (3 people among ~100), but it also means we have not hired anyone new since mid-2022. And where I used to see maybe 4-8 people yearly leave in order to hop to a new job, I think I've seen 1 person do that in the whole last year and a half.
All this to say it's rough and I can't just say "send applications and believe in yourself :)".
I have done interviews though. (I'm not involved in resume screening though, just the interviews of candidates who made it past the screening phase.) So I have at least some relevant advice, as well as second-hand knowledge from other people I know who've had to hop jobs or get hired recently.
If you have friends already in industry who you feel comfortable asking, reach out to them. Most companies have a recommendation process where a current employee fills out a little form that says "yeah I'd recommend such-and-such for this job." These do seem to carry weight, since it's coming from a trusted internal person and isn't just one of the hundreds of cold-call applications they've received.
A lot of tech companies--whether for truly well-intentioned reasons or to just check a checkbox--are on the lookout for increasing employee diversity. If you happen to have anything like, for example, "member of my college Latino society", it's worth including on your resume among your technical skills and technical projects.
I would add "you're probably gonna have to send a lot of applications" as a bullet point but I'm sure you're already doing that. But here it is as a bullet point anyway.
(This is kind of a guess, since it's part of the resume screening) but if you can dedicate some time to getting at least passingly familiar with popular tech/stacks for the positions you're looking into, try doing that in your free time so you can list it on your resume. Even better if you make a project you can point to. Like if you're aiming for webdev, get familiar with React and probably NodeJS. On top of being comfortable in one of the all-purpose languages like C(++) or Java or Python.
If you get to the interview phase - a company that is good to work for WILL care that you're someone who's good to work with. A tech-genius who's a coworker-hating egotistical snob is a nuisance at best and a liability at worst for companies with even a half-decent culture. When I do interviews, "Is this someone who's a good culture fit?" is as important as the technical skills. You'll want to show you'll be a perfectly pleasant, helpful, collaborative coworker. If the company DOESN'T care about that... bullet dodged.
For the technical questions, I care more about the thought process than I do the right answer, especially for entry-level. If you show a capacity for asking good, insightful clarifying questions, an ability to break down the problem, explain your thought process, and backtrack&alter your approach upon realizing something won't work, that's all more important than just being able to spit out a memorized leetcode answer. (I kinda hate leetcode for this reason, and therefore I only ask homebrewed questions, because I don't want the technical portion to hinge at all on whether someone managed to memorize the first 47 pages of leetcode problems). For a new hire, the most important impression you can give me is that you have a technical grasp and that you're capable of learning. Because a new hire isn't going to be an expert in anything, but they're someone who's capable of learning the ropes.
That's everything I have off the top of my head. Good luck anon. I'm very sorry you were born during a specific range of years that made you a new grad in 2024 and I hope it gets better.
320 notes · View notes
nikjag · 1 year
Text
leetcode
i dont get practicing by using leetcode over projects why cry over one small problem when you can cry over a dozen interwoven ones at the same time? i thought computer scientists liked efficiency
252 notes · View notes
shieldfoss · 3 months
Text
I Have No Job, and I must C++
Tumblr media
Yes this is an obvious grab for praise for solving a leetcode easy.
Nevertheless, I feel like "literally the best attempt anybody ever made" is uh... It's pretty good.
It's not even my best because I think I have a dodge against an adversarial input that will speed it up significantly.
(and I haven't started parallelizing the problem yet)
32 notes · View notes
izicodes · 2 years
Note
hi there, i'm trying to get into the coding community so to speak. what sites can i join to discuss/do coding related stuff? I know about stack overflow, github and leetcode but i'm sure there are more, do you have any advice on which spaces are worth joining? thanks!
Communities To Join For Coding/Programming
Tumblr media
Yeah I can help! In terms of "which spaces are worth joining" would depend on you. What I see as a place worth joining is a place where I can teach others - I like giving knowledge back on what I learnt so some places that I listed don't work well for me to do that and some others I prefer the most like the discord servers I'll mention. So, you'll have to skim through these and see if they're something you like!
Anyhoo, here are some places I found:
Reddit: There are many subreddits dedicated to coding, such as r/learnprogramming, r/coding, and r/programming. You can also find subreddits dedicated to specific programming languages or technologies so you can get specific help or provide the help to those languages etc.
Codecademy Forum: They have a forum and a discord server where you can talk about the courses and get buddies to do projects together who are at the same level as you!
FreeCodeCamp Forum: This website offers free coding lessons and projects, and also has a community forum where you can ask for help and connect with other learners. I met 2 developers from there who helped me a lot.
Dev.to and Medium: Both a community where developers come to share their knowledge and experiences through blog posts and discussions. Developers sometimes gain good writing experience by writing these posts (great way to move towards being a technical writer). I've made a Dev.to account and I'm slowly adding my programming posts from here to there and I want to start using Medium too 🤔
Discord: There are many Discord servers dedicated to coding, where you can join discussions and get help with coding problems. I made a whole post with a list of discord servers I'm part of and would recommend it if you want to get into it! I made lots of developer friends from the discord servers. Intimidating at first but slowing you'll like it I think! I'm mostly there to help people with HTML and CSS problems and you can help people the same with whatever. you're strong in!
In the end, the websites and communities you choose to join will depend on your interests and goals. I recommend exploring a few different options and finding the ones that work best for you - I did that and I preferred the discord servers over the subreddits 😅
Good luck with your coding journey! 😸👍🏾💗
191 notes · View notes
eightyonekilograms · 9 months
Text
Oh my god I'm actually doing a leetcode-y algorithm problem for a real need, for like the first time in my career. And I think it needs dynamic programming even!
(The issue is, I have a set of "sessions" consisting of a start time plus a duration, and I want to know the max number of concurrent sessions. I have a vague memory that I've even seen this exact problem-- except rephrased as line segments of start point plus length-- in Cracking the Coding Interview or something)
42 notes · View notes
triviallytrue · 1 year
Text
A LLM got 12th in a Leetcode coding contest (probably)
In Weekly Contest 344, a fresh account (gogogoval) solved all 4 problems in 12:13 with commented submissions and test cases that look a lot like LLM code.
This could've been faked, but I doubt it. There are a small group of people in the world (a thousand, maybe) who could solve this contest fast enough to get 12th and add comments (or solve the problems and then feed it to a LLM to add comments), but it would be a very odd thing to do on a fresh account. The code itself also looks like LLM code - it uses techniques like gets on dictionaries (instead of using defaultdicts like most competitive python programmers).
This isn't that impressive. Leetcode contests are pretty easy, and this was an unusually easy contest - all four of the problems are rated easy or medium. Leetcode contests at the top level are about speed, not depth of understanding, so it's not that shocking that a LLM could do very well.
It's still a pretty massive leap. The free version of ChatGPT can solve two of these questions with some prodding, but it's pretty helpless on the other two. In particular, the last problem (the paths through a binary tree) is not trivial - it took me about ten minutes to find and implement a solution last night, and I'm pretty good.
This isn't that big of a deal for competitive coding, but it is a big deal for both Leetcode and the online assessments companies give. I don't know how much prompting or bugfixing it took the human who submitted this code to get the LLM to a correct solution, but either way, it changes the game on how we think about easy problems. We've gone from models that were very dull to a model that could probably pass the first round of a FAANG interview for a new grad. Already, in the week after, a skilled coder used a LLM to solve the first two questions of the Leetcode contest while solving 3 and 4 manually, saving a bunch of time and getting rank 5 in the contest. Easy questions aren't useful discriminators anymore.
This is the first thing I've seen a LLM do that genuinely impressed me. We are steadily approaching a point where either the improvement will slow or these things will have massive economic impact, and I have no idea which will happen.
122 notes · View notes
codemerything · 8 months
Text
4th February, 2024 TLDR: 📌read Chapter 3 of Grokking Algorithm 📌solved one leetcode problem on Binary Search 📌started a course on optimizing your LinkedIn profile 📌completed the navbar of my second project
Tumblr media
Logic (Anything that has to do with programming & work will be explained under logic):
Earlier today I was trying to solve this leet code problem and i didn't figure it out because i was too tired but later found the answer and spent the next 1 hour trying to understand why i couldn't solve it --
Tumblr media
i thought of using maps but i didn't know how to update the maps but later found out how to but i always have that issue with updating an array to perform a particular task. I am also currently working on a project called Tubyte and I was able to complete the navbar to the project today and I am using Next, React for the frontend. It's a CMS, I will talk more on it later
Tumblr media
11 notes · View notes
excludedmiddle · 1 year
Note
hey congrats on reaching CM (? wanted to find the post where you mention that to confirm but tumblr search misbehaves). was curious as to how many problems you've solved on cf? I primarily picked it up cause ik it helped friends with interview stuff but I'm 2 months in stuck at ~1200 so wondering if I should be doing things differently. on one hand most problems <1400 are greedy or math so I worry an actual interview will be more "algorithmic" and I'll be unprepared (maybe leetcode is better in this regard?). on the other hand it's soo much easier to fantasise about being good at cp than actually practicing. so. anyway wondering if you had any advice on this? CM in one year does not sound like the journey of your average cf-er. congrats again. cheers!
Thank you!
(full disclosure: I've kind of fallen off with competitive programming - I haven't competed on codechef since January and codeforces/leetcode since April)
My solving totals, ratings, and number of contests are:
Leetcode: 824 problems, 2571 rating, 41 contests
Codeforces: 69 problems, 2000 rating, 14 contests
Codechef: 32 problems, 2046 rating, 4 contests
If you're looking for interview prep I would skip codeforces. Leetcode problems are closer to what you'll get in interviews, and their contests are much less of a time commitment. I also code in Rust on CF/CC and Python on Leetcode, and I much prefer to take interviews in Python.
If you snoop around a bit on reddit and the leetcode forums, you can often find lists of problems people have seen at a specific company's interviews to get a flavor of what you're up against. I really recommend this - the problem I struggled with the most in getting my current job was on one such list for my company and I wish I'd gone through the list. This was before I got really good, though.
I think my rapid growth was fueled by three things:
I did math competitions all the way through college that have a similar skillset
My college classes taught a lot of competitive programming concepts (I learned what a SegTree was in class!)
I had a period of 5 months between graduating and starting my job where I was unemployed and highly motivated, and I did a ton of grinding during that period. Most of my leetcode solves are from that time
If you're looking to improve but don't have a ton of time to burn, here's the regimen I recommended to another asker:
Tumblr media
24 notes · View notes
viivi1432 · 11 months
Text
Day 1 of 100 days Coding Challenge
Completed LeetCode daily challenge problem. Did some questions on arrays. Revised some concepts of MongoDB.
19 notes · View notes