Skip to content
Paras Gupta

Jan 1 - Daily Programming Diary

Diary, Programming2 min read

11:50

Woke up on time today (really!), and I thought "It's new year, let's build some habits.". I went ahead and completed the blog on Arch installation. Feels like a milestone to be honest. I mean it's great to have someone who's constantly asking you to complete a task.

I also decided to go ahead and start this blog as my daily programming journal. I think only I can hold myself accountable.

12:50

Installed Go. Wow the internet seems to want me to work today. xD

14:06

Just completed the Leetcode January Challenge Day 1. Although the problem seemed a bit challenging, I used hash table to store the first element of each piece with the respective vector. When I encounter the first number of a piece in array, I fetch the array and compare till the piece finishes.

check-array-formation-through-concatenation.cpp
1bool canFormArray(vector<int> &arr, vector<vector<int>> &pieces) {
2 unordered_map<int, vector<int>> umap;
3 for (int i = 0; i < pieces.size(); i++) {
4 umap[pieces[i][0]] = pieces[i];
5 }
6
7 for (int i = 0; i < arr.size();) {
8 if (umap.find(arr[i]) == umap.end()) {
9 return false;
10 } else {
11 for (int j = 0; j < umap[arr[i]].size(); j++) {
12 if (arr[i + j] == umap[arr[i]][j]) { }
13 else {
14 return false;
15 }
16 }
17 i += umap[arr[i]].size();
18 }
19 }
20
21 return true;
22}

The time complexity is O(n) even with the nested loop, and the space complexity is also O(n).

Optimization? Trade-off!: The hash table could be eliminated and sorting implemented which would take O(nlogn) time and O(1) space.

Break!

15:16

Helped Deepesh install arch on his PC, and failed miserably. I still don't know what went wrong. 🤦‍♂️

17:14

Okay, I'm back. Getting started with Codechef long challenge. This time they have 3 divisions and I feel like it's not really worth the effort to solve these questions, but you know I will probably get better questions next month. I'll just put the questions that I was able to solve today since it's a live contest and I don't want Codechef to ban me. Oh I have an idea, I'll post the submission IDs and Codechef will deny access until the contest ends. **pats on back!

Today's Questions:

  1. Problem DIVTHREE -> Solution 41008830
  2. Problem DECODEIT -> Solution 41013204
    Wow this question was not difficult in itself but it was hard to implement. The ASCII conversion and substring had me occupied for a while.
  3. Problem FAIRELCT -> Solution 41015617
20:00

I finally got around to working on the last task of the day. I'm exhausted but I thought, if not anything else, at least I should start making sense of the documentation. Decided to write the traditional Hello World! program and test stuff out.

1package main // For grouping functions
2
3import "fmt" // Package for formatting text
4
5func main() {
6 fmt.Println("Hello World!"); // For printing
7}

Weird things:

  • It's a lot like Java, I mean packages? I don't even remember how they work 🤦‍♂️
  • The strings can only work with "double quotes". I KNOW! Judging too harshly? Coming from JavaScript with the template strings and what not, it's a bit inconvenient.
  • And what is this with the func keyword

For what it's worth, it wasn't a complete disaster of a day. Godspeed.

Break

Gonna watch a movie now, and probably work on the Raahee report feature later. Hope I sleep on time today.

Later!
00:10

Started working on Raahee Reported content feature. Really tired today so entire focus on functionality right now!

00:40

Had to set up the project quite a lot, the small issues that projects have with dependencies. I just wanna sleep now! Anyway, I completed the data and display, just have to use it tomorrow to make a nice UI. For now, good night!

EOD Checklist

  • Go
  • Leetcode January Challenge
  • Codechef Long Challenge
  • This blog
© 2022 by Paras Gupta. All rights reserved.
Theme by LekoArts