DEV Community

Dynamic Prograahh..f
Dynamic Prograahh..f

Posted on

Day 3

Today was a very anxious day.
I had an interview for a Node.js intern position. It was round 1 of the interview and it was a group discussion with some of the other shortlisted candidates on some topics provided by the host.
So now, my problem, I GET TOOOOOOOO ANXIOUS. I had not been feeling hungry from the morning itself, P.S. just because I got the email late at night, after dinner, else wouldn't have had dinner also. :")
Anyway, I stop feeling hungry, start feeling like going to the bathroom again and again and nervous.
I even messed up my intro by not mentioning my OSS contributions, because I was just too nervous to remember it!
Anyway, coming to my daily dose of DSA. I did the following questions today:

PROBLEM 1: 2-Sum: Solved it optimally. Had solved earlier also.

PROBLEM 2: 4-Sum: Solved it optimally.

PROBLEM 3: Longest Consecutive Sequence: Solved it. Easy question

PROBLEM 4: Largest number of subarray with k-sum:
PROBLEM 5: Largest number of subarray with k-xor: Now both these problems. I have O(n^3) solution. I was able to take it down to O(n^2) on my own. But I wasn't able to figure out the O(N) approach. I did have an idea about the xor one. But missed one case, where curXor == a[i].
But I understood both of them. Marked for revisit.

PROBLEM 6: Longest Unique character Substring: Was able to solve optimally.
One thing to note and carry forward from this question is that, we have always use hash maps in O(1) time and O(1) space for string related questions, cause there would be at-most all the characters, which is constant. ( 126 I think )

Top comments (0)