Overview
No one can ever follow all the good advice they hear.
We
hear a lot of advice
in our daily lives. But the question here is, do we follow all those regularly? Might or might not be. ๐คงWe
must have given a lot of advice
to others. But do the other party follow those religiously? Might or might not be. ๐ซฃ
If we start listening to all the advice that we get in our lives, we might not be in an effective position. Most of the advice doesn't matter. What worked for person A might not work for Person B.
For eg: Reading a few pages of a book daily. It might change Person A's behaviour, but it might or might not do anything good for Person B.
To not get stuck in this paradox, we can follow the below framework.
Take the advice. ๐๐ฝ
Check if the advice aligns with your values and doings. ๐ค
Filter those which make you a better person than yesterday. ๐ฅต
Implement the advice
if it falls under your filter. ๐ค๐ฝIgnore the noise
if it doesn't. ๐
This art of filtering the advice and implementing takes time. It requires some effort from our end to carefully select or ignore the advice. We should take full control of what works for us. ๐ค๐ฝ
References
The below article clearly explains the concept of the paradox of advice.
Bonus content
Question 8:
Explanation:
To solve this problem, we need to
link the references
(the next node) to the bigger node value.We can do this in place by using a
dummy node
that keeps track of changing the next node.If we see a lesser node, add the reference to the
head
and move forward.We carry out this operation until one of the lists becomes empty.
We finally merge the nodes that are yet to be merged to the
head
node.
Solution:
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class Solution {
public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
// Edge cases
if (list1 == null && list2 == null) {
return list1;
}
if (list1 != null && list2 == null) {
return list1;
}
if (list1 == null && list2 != null) {
return list2;
}
// Maintain a temporary node.
ListNode head = new ListNode(-1);
// Maintain the reference as well so that we can return it.
ListNode headRef = head;
while(list1 != null && list2 != null) {
if(list1.val <= list2.val) {
head.next = list1;
list1 = list1.next;
} else {
head.next = list2;
list2 = list2.next;
}
head = head.next;
}
// Cases when one of the list is exhausted.
if(list1 != null) {
head.next = list1;
}
if(list2 != null) {
head.next = list2;
}
return headRef.next;
}
}
Next problem:
In the next post, I will cover the below problem.