News for hackers. Stuff that matters.

Tmp1234

Your solution looks better than mine. Is there anything you've gleaned from the leetcode examples I posted?
Thank you for all the effort you put in this comment! That's definitely an interesting path methodology you've laid out. I will give it a try. Would you be willing to talk more as I go through the process?
Any books in mind?
Yes. Very much so.
I enjoy it, but not given the failure rate I'm experiencing. If I had 50% or less failure ratio I would be ok. But as is essentially every problem is a 2-5 hour struggle where I meander to an answer feeling usually I temporarily learned why X didn't work in that given situation and not something widely applicable.
This is basically my thinking :/
This doesn't sound half bad. How can I find these?
My view has been they are looking for people with high IQs exclusively. Whiteboard interviews cut out people who are not even intelligent enough to memorize solutions and algorithms while also accepting people smart enough to come up with solutions to tough problems they haven't seen before. It seems given how much I struggle I may not even fit in the memorize 300+ leetcode category.

I'm very interested in this divide between people who are for white board interviews and against it and how it correlates with job performance and content. I may make a separate post about it because I'd like to get to the bottom of it.

For the median question, I did not allow myself to combine the array. My idea was to increment in each array based on which value would come next in a sequence (as if they were on array), stop when I've incremented n times where n = length of both arrays / 2 (the median position) and then return. Here's the code:

class Solution: def findMedianSortedArrays(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: float """

        length = len(nums1) + len(nums2)
        medianIndex = length // 2
        ptr1 = 0
        ptr2 = 0
        curr = 0
        flag = 0
        
        if nums1[ptr1] < nums2[ptr2]:
            val = nums1[ptr1]
        else:
            val = nums2[ptr2]
        
        while curr < medianIndex:
            if nums1[ptr1] == val:
                if nums2[ptr2] < val:  
                    curr += 1
                    ptr1 +=1
                    val = nums1[ptr1]
                    flag = 0
                else:
                    if ptr1+1 < len(nums1) and abs(nums1[ptr1+1]) - abs(val) < abs(nums2[ptr2]) - abs(val):
                        curr+=1
                        ptr1+=1
                        val = nums1[ptr1]
                        flag = 0
                    else:
                        curr+=1
                        val = nums2[ptr2]
                        flag = 1
            else:
                if nums1[ptr1] < val:  
                    curr += 1
                    ptr2 +=1
                    val = nums2[ptr2]
                    flag = 1
                else:
                    if ptr2+1 < len(nums2) and abs(nums2[ptr2+1]) - abs(val) < abs(nums1[ptr1]) - abs(val):
                        curr+=1
                        ptr2+=1
                        val = nums2[ptr2]
                        flag = 1
                    else:
                        curr+=1
                        val = nums1[ptr1]
                        flag = 0
        
        if flag == 1:
            med = nums2[ptr2]
        else:
            med = nums1[ptr2]
            
        if length % 2 == 0:
            if med - nums1[ptr1 + 1] < med - nums2[ptr2 +1]:
                return (med + nums1[ptr1+1])/2
            else:
                return (med + nums2[ptr2+1])/2
        else:
            return med
Here's what I wrote for your sum the cubes. Took me 1 minute. I hope I didn't misunderstand the question.

def sumCubes(n): sumC = 0 for i in range(n+1): sumC += i 3 return sumC

I'll give you 2 more leetcode examples. Neither passed all test cases. The first is 2-3 hours. The latter 3. I didn't post the last submission for the latter one because I believe the one I posted is more telling of my thought process and coding ability imo so that solution is between 1 and 2 hours of work, but I wasn't able to get it in the end.

I honestly don't recall my idea here. I think it was to see if the start and end of the array had the same letter and if it didn't cut off the first and last letter and continue analyzing the array until the center is reached.

https://leetcode.com/problems/longest-palindromic-substring/...

class Solution: def longestPalindrome(self, s): """ :type s: str :rtype: str """ curr = "" big = ""

        for c in s:
            curr += c
            if curr != curr[::-1]:
                if len(curr[:len(curr)-1]) >= len(big):
                    big = curr[:len(curr)-1]
                    print(big)
                while curr != curr[::-1]:
                    curr = curr[1:]
        
        if len(curr) > len(big):
            return curr
        else:
            return big
I thought there were 3 cases in this problem. You hit a character, you hit a ? or you hit . The first one meant an exact match had to be made. The second that there only had to be some character in the string to take a position (the string couldn't end if there was a ?). The last could mean 0 to n matches so there had to be a lot of checks in my mind. I also thought about what happens if there's "?" which I wrote as a case inside the "" if case. When test cases didn't work I would try and code for that test case and it kept going wrong so I eventually gave up and looked at the solution. My main flaw is that it didn't occur to me that backtracking was the way to go or a way to check all the potential combinations. I thought you just had to keep moving forward.

https://leetcode.com/problems/wildcard-matching/description/

class Solution: def isMatch(self, s, p): """ :type s: str :type p: str :rtype: bool """ if len(p) == 0 and len(s) == 0: return True if len(p) == 0: return False

        i = 0
        j = 0
        while i < len(s):
            if j >= len(p) and p[len(p) - 1] != '*':
                return False
            
            if p[j] == '*':
                while j < len(p) and p[j] == '*':
                    j+=1
                if j == len(p):
                    break
                elif p[j] == '?':
                    x = len(p)- j
                    while len(s) - i > x:
                        i+=1
                    while j < len(p) and p[j] == '?':
                        i+=1
                        j+=1
                    if i > len(s) or j >= len(p) and i < len(s):
                        print(i)
                        return False
                    if i == len(s) and j == len(p):
                        break
                else:
                    while i < len(s) and p[j] != s[i]:
                        i+=1
                    

                    if i == len(s):
                        return False
            elif p[j] == '?':
                i+=1
                j+=1
            else:
                if p[j] != s[i]:
                    print(i, s[i])
                    print(j, p[j])
                    return False
                i+=1
                j+=1
        
        if j < len(p):
            while j < len(p) and p[j] =='*':
                j+=1
                
            
            if j == len(p) and p[j-1] == '*':
                return True
            else:
                return False
        return True
You're not wrong that there's a mental health issue at hand. There's also a lot riding on my ability to do these leetcode questions. I've been talking to councilors for the past decade, but I'm at a point where I need to be financially independent. I wrote more about it in this comment:

https://news.ycombinator.com/item?id=17594084

Thank you for this resource!
I agree that some of the problems are too hard to be realistic. I made sure to not count those when I was analyzing my performance. As I said in the comment I'm linking to below, a few months ago I couldn't even do Fibonacci recursively. I just couldn't figure out how to structure the code, when to call the function, how to pass the results of each call up the stack etc. This is just one example. The other day I tried to do the brute force implementation of finding the median of 2 sorted arrays. Brute force as in have two pointers at the start of each array incrementing until you reach the median. It was too hard for me to code successfully and I spent 2-3 hours on it.

I wrote a comment that I realize should have been part of the original post on hindsight. It may give you more content if you choose to respond.

https://news.ycombinator.com/item?id=17594084

I added a separate comment to add some information about my situation. It addresses your question and advice too.

https://news.ycombinator.com/item?id=17594084

I didn’t expect this many responses. It’s a bit overwhelming, but I'm thankful. I’m going to post a few important pieces of information I didn’t think of posting above that should help clarify my situation and how desperate it is.

I do have depression. Pretty bad one actually. I am just graduating from college at 31 because of the toll depression took on my life. I have no previous work experience because I spent my 20s just being depressed doing nothing basically. I've talked to therapists for years now and it's helped, but I've basically gone as far as that can go. My therapist and I both agree that basically as much as can be done from me through a psych has been done. My life needs to improve. Programming was supposed to be my ticket to a better life.

Some people have mentioned I should move home- My home environment is extremely toxic. I’ve cut off my mother completely because she has a severe, much worse mental illness and I only talk to my dad when I need something because he has quite the temper. I managed to get out of the house only because I’m on disability for my depression. To make things worse, my dad is past retirement age. Every single day I’m not making money forces my dad to prolong his retirement as he is the only one in the family with the mental faculties to maintain a job. It should be easy to imagine how this makes him more irritable and angry while also making me feel incredibly guilty and parasitic. This fragile economic state + my age is why I don't really have time to take it easy. I was supposed to be making money yesterday.

I’ve been preparing for technical interviews for over a year in reality, but intensely in the last month or 2. I couldn’t do Fibonacci recursively up until a few months ago until I looked it up and studied how the recursion was working. This is just one example. There are so many very basic things I can’t do.

Finally, I can’t depend on a network or friends in any form because I have none. I am a complete pariah in the computer science community I come from and every other community I’ve ever tried to integrate myself into, basically. No one will ever refer me to any job because no one likes me and, in the case of programming, everyone knows I suck.

Ask HN: Got a CS degree, but I’m unable to be programmer. What can I do?

I recently graduated and have been grinding for interview prep (leetcode and CTCI mostly), but I’m getting no where. Easy problems take me 2-5 hours. I experience PTSD like symptoms from the constant barrage of negative thoughts the difficulty and stress of doing these problems are causing me. I don’t have time to do anything else and no objectively measurable progress is being made. Even if I...

( Read More... | 315 comments | 294 points | on HN )
Re:How did you get where you are? on Wednesday July 18, 2018 @12:02AM (#17555501)
I'll look at Triplebyte's blog. Another resource I didn't know about you've pointed me to.

>>Personally, I can assure you that it isn't a matter of disliking you. Honestly, if I didn't like you, I wouldn't have posted here at all. I like you and want to help you, just not under the terms that you outlined.

Well, my problem is not being able to determine if I should quit trying to become a programmer specifically because of lack of ability. If you can help me make that decision I welcome it. Probably would make more sense if we PMed about this though.

>>As for the part about the correlation between the role of IQ and satisfaction as a software engineer, I might be hearing you wrong. I think that you're saying that repetitively debating the same subject annoys you. Am I right, or are you saying that you find the particular topic of IQ annoying?

Both are true. I don't like repeat debates that go no where nor do I like the primarily ideologically based stances people have on IQ and natural ability in general.

What I was asking was in relation to you saying- "if having a discussion about IQ's value in software development is that annoying to you, I worry that this field would make you profoundly unhappy." So I don't know why I would be unhappy as a developer because I wouldn't want to argue with people about IQ. It almost seems like you're saying arguing about IQ is a necessary part of the job and one that must be enjoyable in order to find satisfaction as a programmer.

Re:How did you get where you are? on Tuesday July 17, 2018 @11:54PM (#17555475)
Nothing about what you wrote is harsh imo.

The questions are just to cast the largest net. Anything someone doesn't want to answer they won't just as no one has responded to the question. I assumed anyone who posted on my thread would share the minimal information. It's not like I have a gun to anyone's head.

I'd view the random stranger thing differently because there's no way anonymous. Here, there is. Plus, a person in your face tends to make people react with more of a sense of obligation than text.

Re:How did you get where you are? on Tuesday July 17, 2018 @01:30AM (#17547520)
I don't understand your point about putting internet reputation at stake. If someone well known and respected asked this question here and people responded earnestly and completely the information is still public and could be accessed by me or anyone else. Thus, the risks are the same regardless of asks the question, aren't they?

As for the length and quantity of the questions, I was just trying to help people think through their responses and specify what I'm interested in learning. The "please don't post if..." part is because whenever I've mentioned IQ in this context there's a huge backlash and every rushes to talk about how it's not important. I wanted to avoid that, but I can see how it rubs people the wrong way.

In the end, this seems a lot more like evoking dislike rather than distrust. The two don't correlate in my brain. I've met many charming people who were not trustworthy and plenty of off putting people who are highly moral. Maybe, I'm really not getting something though.

Re:How did you get where you are? on Monday July 16, 2018 @09:22PM (#17546577)
I never knew about those surveys. Thanks for pointing them out. They don't seem to get at what I'm seeking though. There are no connections drawn between innate ability, self described difficulty in the field and thresholds of prestige and compensation reached given the first two which is what I'm interested in. Maybe, I'm not looking at the data in the right way though.

I'm open to whatever advice you have to offer even if it comes along with "battering." I would posit though, and correct me if I'm wrong, that what maybe you don't like what I've said rather than you not trusting me? I can see how the sort of bluntness I used can be off putting to some and how the nature of the questions are inherently personal and thus uncomfortable, but I struggle to see how anything I wrote makes me seem malicious or untrustworthy. I know people tend to distrust what they dislike and trust what they like which is a huge fallacy, but a heuristic many people feel comfortable acting on or, perhaps, don't even notice they act on. If that's not the case here though, I'm very interested in why you feel distrust.

I don't see any correlation between enjoyment of the discussion about the role of IQ in software development and satisfaction as a software engineer. Can you explain what you mean?

Re:How did you get where you are? on Monday July 16, 2018 @07:45PM (#17546134)
If you don't want to share, that's fine. I'm just trying to get some data to help me make a choice in my own life about my career.

My experience has been bringing up intelligence or IQ automatically people always bring up a set of counterarguments on why it doesn't matter or shouldn't be focused on and because people sometimes say things like "I took an IQ test on X.com and got 234" cause those are not accurate. I'm trying to prevent those responses.

How did you get where you are?

I’d like to get a collection of the following things from the programmers who come on here:Your subjective experience coding and your story- How long have you been coding? How difficult has it been? Are you noticeably quicker/slower or less/more skilled than your peers? How hard did you have to work and study to get where you’ve gotten? What were the roadblocks? Do you have any lessons and...

( Read More... | 11 comments | 3 points | on HN )

Outcome and story thread++

I’d like to get a collection of the following things from the programmers who come on here:1 Your subjective experience coding and your story- How long have you been coding? How difficult has it been? Are you noticeably quicker/slower or less/more skilled than your peers? How hard did you have to work and study to get where you’ve gotten? What were the roadblocks? Do you have any lessons and...

( Read More... | no comments | on HN )

How to know if you're not smart enough to be a great programmer?

I'm at a crossroads where I'm considering whether I should give up trying to be a programmer, specifically, a programmer worthy of a Big 4 job. I've been struggling daily with doing even leetcode/CTCI questions, not being able to implement even brute force solutions to relatively simple problems. It's been a month since I've been doing problems daily, but I've been trying my luck at tech...

( Read More... | 5 comments | 4 points | on HN )
Re:Ask HN: Should I quit trying to be a programmer? on Friday July 13, 2018 @12:44PM (#17524485)
How would you distinguish between someone who doesn't have enough experience and someone who is smart enough?
Re:Ask HN: Should I quit trying to be a programmer? on Friday July 13, 2018 @12:43PM (#17524479)
It seems we both agree, indirectly, that these interview tests are like IQ tests. You are comparing them to the SATs and the SATs are just wrapped up IQ tests like the tech interview. Studies have shown scores on the SAT don't increase by more than 100 points or so even with 100s of hours of practice. In the end, the algorithmic thinking you mention just seems like another way of saying intelligence which would be a factor in any subfield I enter.

And the truth is I've been doing interview prep on and off for at least a year and I'm still at this stage. My goal is to be good enough to get into a Big 4. If I can't do that, I don't want to continue. Given that, do you think I should quit?

Re:Ask HN: Should I quit trying to be a programmer? on Friday July 13, 2018 @12:36PM (#17524431)
Could you expand a little? It's a big life decision I would be making.
Re:Ask HN: Should I quit trying to be a programmer? on Friday July 13, 2018 @12:36PM (#17524424)
I don't have the resources for a 1 on 1 tutor. Do you have any other ways for me to know objectively if I should quit?
Re:Ask HN: Should I quit trying to be a programmer? on Thursday July 12, 2018 @03:45PM (#17517998)
I enjoy programming, but I don't like constantly failing, feeling I'm not good enough and having no spare time cause even a single basic prep question takes me 2-3 hours.
Re:Ask HN: Should I quit trying to be a programmer? on Thursday July 12, 2018 @03:44PM (#17517986)
If I was only interested in programming to become a google worthy programmer, would you say I have enough evidence that I should quit?
Re:Ask HN: Should I quit trying to be a programmer? on Wednesday July 11, 2018 @11:40AM (#17507760)
The thing is I have no idea I need more planning. When I start to code the solution I've come up with seems genuinely complete and correct. It's only when the incorrectness hits me right in the face, usually in the form of test cases failing or not being able to code something I thought I could, that I realize I didn't have it.

To be concrete, yesterday I tried to solve this question: https://leetcode.com/problems/wildcard-matching/ I spent 45 minutes on the planning phase which would be the entire time I'd have for the problem in an interview. I had some pseudocode, thought through it, tried an example or two and then decided to code it up. As I did I realized a few more examples which I added in. Finally, I had some code that seemed even more correct than the code I thought was already correct. I run it and test cases fail. I spent 2.5 hours in total trying to get them all to pass without realizing the central issue of the question is what to do when you hit a * character. The necessity to try all the combinations of the string after a * doesn't not occur to me in 2.5 hours; I kept tweaking for specific cases I was failing. I ask a friend about the problem and in less than two minutes he realizes you need to try all combinations.

>>What sort of ideas and logic are you specifically having problem with?

It seems everything. Sure, some problems turn out to have an algorithm that I didn't know about it. Like the other day I was trying to do a problem that basically needed topological sort and I never really learned top sort. But then I read in the solution in CTCI that it's reasonable to derive that on one's own in a 45 minute interview so there goes that. More generally, it just seems when a problem reaches a certain level of difficulty my brain simply can't solve it. I suspect it's an intelligence thing. I just don't have a high enough IQ to get passed a certain point.

I will look at the resources you mentioned.

Older »