— Diary, Programming — 1 min read
I completed the Question 5 WIPL on Codechef last night but was too tired to write here.
The concept was to try and take minimum boxes first that can make a stack on 2*k
size and check if we can make individual stacks from those.
The solution can be found at 41276886.
Also got 30 points in Question 6 ANTSCHEF. Just had to use long long
for the result from yesterday.
Leetcode January Challenge Day 5. Starting now!
The question is pretty simple. Just have to check the next and prev values to ensure that current element is not duplicate.
1ListNode *deleteDuplicates(ListNode *head) {2 if (!head) return head;34 ListNode *ans = new ListNode(-1000);5 ListNode *temp = ans;6 int prev = -1000;7 while (head->next != NULL) {8 if (head->val != prev && head->val != head->next->val) {9 ans->next = head;10 ans = ans->next;11 }1213 prev = head->val;14 head = head->next;15 }1617 if (head->val == prev) {18 ans->next = NULL;19 } else {20 ans->next = head;21 }2223 return temp->next;24}
Time complexity O(n), space complexity O(1).
Have to work on Raahee feature tomorrow for demo on 7th. Getting the report feature ready is a large task considering the time I have. In any case, not feeling like working any more today. So I'll get back tomorrow.
Also, this blog needs a feature for me to write something and only show when I'm logged in. I mean, what if I want to write about my feelings? Gonna do that after completing the Raahee features.
Sayonara!