Skip to content
Paras Gupta

Feb 1 - Daily Programming Diary

Diary, Programming1 min read

Back from Gurgaon (Gurugram!?). The Samsung test went fine. I think I should get selected but I'm still not sure about the shortlisting criteria. But then again, I gave my best, passed the testcases and all is left to fate now. :)

The TCS test was also good but then I wasn't able to attempt all the questions in "Quantitative Ability" section.

9:00

There is some bug with the class script that I wrote. Although it saves a lot of time that is spent doing that redundant task of looking at time table, and getting the link from google classroom, the 9am weird bug is something that I need to fix.
As it turns out, I had to use -lt and not -eq when comparing $CURRENT_HOUR.

It's so efficient.

11:00

It's the last few hours of January (on Leetcode) and I wanted to get the last questions done before it ends. So the question demands the deviation to be reduced. The thinking is that the max number if even should be divided by two until the max number is odd. Then the difference will be minimized.

minimize-deviation-in-an-array.cpp
1int minimumDeviation(vector<int> &nums) {
2 set<int> s;
3 for (auto i : nums) {
4 s.insert(i % 2 ? i * 2 : i);
5 }
6 int res = *s.rbegin() - *s.begin();
7 while (*s.rbegin() % 2 == 0) {
8 s.insert(*s.rbegin() / 2);
9 s.erase(*s.rbegin());
10 res = min(res, *s.rbegin() - *s.begin());
11 }
12 return res;
13}
14:00

February Leetcode Challenge is live. Question for today just wants the number of 1s in the binary representation of a number. Just keep on dividing the number by 2 and adding the remainder at all steps.

number-of-1-bits.cpp
1int hammingWeight(uint32_t n) {
2 int ans = 0;
3 while (n != 0) {
4 ans += (n % 2);
5 n /= 2;
6 }
7
8 return ans;
9}
15:00

Working on the HackOn Hackathon website. The first task for me is to set that background image on the Hero section. Since I'm not so comfortable with the front end aspect of web development, it took a some time to get familiar with Nuxt.js as well as Vue.js. Time to get started.

17:00

Took me a while to get familiar with the code base and the asset referencing in Nuxt. But then the image positioning and gradient was a difficult part as well. Finally it looks like 80% similar to the Figma design. Why do I want stuff in a perfect manner. It's a bane. :/

Made the PR, let's see what haxzie says.

Feeling so sick, I wanna sleep.

Goodbye!

EOD Checklist

  • Leetcode February Challenge
  • This blog
© 2022 by Paras Gupta. All rights reserved.
Theme by LekoArts