The paradox of advice

Karthick RamjeeKarthick Ramjee
3 min read

Overview

No one can ever follow all the good advice they hear.

  1. 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. ๐Ÿคง

  2. 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.

0
Subscribe to my newsletter

Read articles from Karthick Ramjee directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Karthick Ramjee
Karthick Ramjee

Software developer from India!