Skip to content
Paras Gupta

Jan 6 - Daily Programming Diary

Diary, Programming, Crio.do2 min read

12:30

Received a mail from Crio yesterday about Winter of doing round 1. Isn't really a big deal since I don't even think they've shortlisted anyone yet. Waiting for the saturday event to learn more and see if it's as good as the hype surrounding it. Starting Raahee work for today.
Tasks:

  1. Add registered users to the collection
  2. Add users on signup
  3. Add report and delete on community
14:30

Worked on Raahee users collection. Damn it was crazy focusing on all the little things so much so that I became frustrated at one point. Still have to add the already registered users to the test DB, and hope it doesn't break the app.

Break!

16:00

Since I haven't been able to keep up with Go and all the other things, I am thinking about moving to Go for solving the competitive programming questions. Now, the single issue with that is I'll either have to write code in C++, or pseudocode first and then in Go which seems a little exhausting but I have to make that trade-off.

When I think about it, it's like learning Spanish. You can't think in Spanish, but what you can do is think in your native language and then translate to Spanish. Following the same philosophy here. :)

Writing code in C++ first.
Approach : If the difference of prev and current element contain k elements, return the kth element from prev element.

kth-missing-positive-integer.cpp
1int findKthPositive(vector<int> &arr, int k) {
2 int prev = 0;
3 int sum = 0;
4 arr.push_back(10000);
5 for (int i = 0; i < arr.size(); i++) {
6 int temp = arr[i] - prev - 1;
7 if (sum + temp >= k) {
8 return prev + k - sum;
9 }
10 sum += temp;
11 prev = arr[i];
12 }
13
14 return 0;
15}

Time complexity O(n), space O(1). Translating to Go now.

kth-missing-positive-integer.go
1func findKthPositive(arr []int, k int) int {
2 var prev, sum int = 0, 0
3 arr = append(arr, 10000)
4
5 for i := 0; i < len(arr); i++ {
6 var temp int = arr[i] - prev - 1
7 if sum + temp >= k {
8 return prev + k - sum
9 }
10 sum += temp
11 prev = arr[i]
12 }
13
14 return 0;
15}
17:55

So I was thinking about writing secrets in here, and I have made a basic component that would take the password and unlock what I wrote.

Try writing parasisgreat in the box and press enter. Oh I know you don't wanna write it but I'm a braggart!

Well you shouldn't be surprised! 😇

Amidst the glory of this, I almost forgot that I also used spell check today for rechecking all the posts. Used markdown-spellcheck for the task.

1npm i -g markdown-spellcheck
2
3# -n for not including numbers
4mdspell -n '**/*6*/**.mdx' '!**/node_modules/**/*.mdx'
21:50

Done with the report feature in Raahee website. Took almost 90 minutes and now I'm tired.

I have also been thinking about the best way to encrypt the data. I can go with standard encryption technique but it would be hard to actually remember the passwords for each document. Then there is an option for auto calculating password based on document slug, which would be a better approach. Also, rather than writing content here, I can just link it to firebase to fetch the content and parse the markdown which makes more sense but then my code is on GitHub. 😕

22:46

Added like feature community page. The code seems to be messed up quite a lot. The database naming scheme used by the app and website teams differ so much that I don't even have the words to express myself.

I think I'm just gonna sleep for now.

Ciao!

EOD Checklist

  • Go
  • Leetcode January Challenge
  • Codechef Long Challenge
  • Raahee
  • This blog (Implemented a new feature)
© 2022 by Paras Gupta. All rights reserved.
Theme by LekoArts