Tuesday, February 6, 2024

Betacap TR 20 Capsule

Betacap TR 20 Capsule

Prescription: Required
Marketer: Sun Pharmaceutical Industries Ltd
SALT COMPOSITION: Propranolol (20mg)
Storage: Store below 30°C

Product introduction

Betacap TR 20 Capsule helps decrease anxiety and relieve tremors. It is also used to help prevent migraine, heart-related chest pain (angina), and bleeding in the stomach caused by high blood pressure in the liver (portal hypertension). Betacap TR 20 Capsule may also be used to treat high blood pressure and some types of abnormal heartbeat (arrhythmia). The dose will depend on what you are being treated for and how you respond to the medicine. You should always take it as prescribed by the doctor. It should be taken on an empty stomach and at about the same time each day. You should keep taking it even if you feel well, as you are still getting the benefits. If you stop taking it suddenly, your condition may worsen. The most common side effects are tiredness, weakness cold fingers and toes (Raynaud phenomenon), irregular or slow heartbeat, numbness in your fingers, and breathlessness. You may also experience nausea, vomiting, and diarrhea. Talk to your doctor if the side effects bother you or do not go away. Most side effects are short-lived and improve as your body gets used to the medicine. You should not use this medicine if you have asthma, very slow or uneven heartbeats, or a serious heart condition, including heart failure. Talk to your doctor before taking it if you have kidney or liver problems or chronic obstructive pulmonary disease (COPD). In terms of lifestyle, alcohol may affect the way this medicine works and should be avoided. You should not drive if this medicine makes you feel dizzy. Ask your doctor whether it is safe to take this medicine if you are pregnant or breastfeeding.

Uses of Betacap Capsule PR

Treatment of Pheochromocytoma Treatment of Hypertension (high blood pressure) Prevention of migraine Treatment of Anxiety Treatment of Arrhythmia Prevention of Heart attack Prevention of Angina (heart-related chest pain) Treatment of Tremors

Benefits of Betacap Capsule PR

In Treatment of Pheochromocytoma While carrying out surgery for the removal of pheochromocytoma, there is a risk of abnormally high blood pressure. Betacap TR 20 Capsule blocks the effect of some chemicals on your heart and blood vessels. This slows down the heart rate and helps the heartbeat with less force thereby lowering your blood pressure. It is used for the immediate reduction of very high blood pressure (hypertensive emergency). Controlled blood pressure reduces the risk of having a heart attack, stroke, or kidney problems. In Treatment of Hypertension (high blood pressure) Betacap TR 20 Capsule relaxes the blood vessels so that blood can flow more easily around your body. This lowers your blood pressure and reduces your risk of having a stroke, a heart attack, or kidney problems in the future. You do not usually feel any direct benefit from taking this medicine, but it works in the long term to keep you well. You should take it regularly as prescribed for this medicine to be most effective, even if you feel better. In Prevention of migraine Betacap TR 20 Capsule helps improve the flow of blood in your brain and prevents abnormal activity of muscles that triggers migraines. It is a very effective medicine for preventing migraine attacks, however, it does not treat an attack that has already started. By preventing and reducing the frequency of migraine attacks, the medicine can help you carry out your daily activities and improve your quality of life. In Treatment of Anxiety Betacap TR 20 Capsule stops your brain from releasing the chemicals that make you feel anxious so it can reduce the symptoms of excessive anxiety and worry. It can also reduce feelings of restlessness, tiredness, difficulty concentrating, feeling irritable and sleep problems that often come with Anxiety Disorder. Betacap TR 20 Capsule will therefore help you go about your daily activities more easily and be more productive. Keep taking this medicine even if you feel well. Stopping suddenly can cause serious problems. In Treatment of Arrhythmia Betacap TR 20 Capsule is used to stabilize heart rate. It helps in normalizing an abnormal heart rhythm, preventing it occurring in the first place or slowing down the heart rate during an episode. In Prevention of Heart attack Betacap TR 20 Capsule helps lower your blood pressure and make it easier for your heart to pump blood around your body. This reduces the chances of you having a heart attack. It can also reduce the risk of dying if it is given immediately after a heart attack. This medicine needs to be taken regularly to be effective, so keep taking it even if you feel well. Do not stop without talking to your doctor. In Prevention of Angina (heart-related chest pain) Betacap TR 20 Capsule relaxes the blood vessels so that blood can flow more easily around your body and makes sure that your heart is getting a good supply of oxygen. This makes it less likely that you will suffer chest pain caused by angina. This medicine can help increase your ability to exercise and go about your daily life more easily by reducing the frequency of angina attacks. You should take it regularly and as long as it is prescribed for it to work effectively. In Treatment of Tremors Betacap TR 20 Capsule helps improve the flow of blood and prevents abnormal activity of muscles that trigger tremors. This medicine can therefore enhance the quality of life by improving the ability to carry out daily functions in a better manner.

Side effects of Betacap Capsule PR

Most side effects do not require any medical attention and disappear as your body adjusts to the medicine. Consult your doctor if they persist or if you’re worried about them Common side effects of Betacap Tiredness Weakness Raynaud's phenomenon Arrhythmia (irregular heartbeats) Nausea Vomiting Diarrhea

How to use Betacap Capsule PR

Use it as advised by your doctor or check the label for directions before use. Betacap TR 20 Capsule is to be taken empty stomach. Avoid Betacap TR 20 Capsule with high-fat meals such as olive oil, nuts & seeds (Brazil nuts), dark chocolate, butter and meat.

How Betacap Capsule PR works

Betacap TR 20 Capsule contains Propranolol, a beta blocker. It works by affecting the body’s response to nerve impulses, especially in the heart. It slows down your heart rate and makes it easier for the heart to pump blood around the body. This prevents arrhythmias. It also widens the blood vessels in the body for better blood flow, thereby preventing angina as well as migraine. The exact mechanism by which it prevents tremors is not known, but experts believe that Betacap TR 20 Capsule helps block the nerve impulses to the muscles responsible for tremors. Propranolol helps block the effects of the chemical messengers namely, adrenaline and noradrenaline, that are produced by the brain and are responsible for increasing your heart rate which makes you feel anxious. This way it helps with anxiety. While treating pheochromocytoma, Betacap TR 20 Capsule may be given to block the action of high-adrenaline hormones, to lower the risk of developing dangerously high blood pressure during surgery for removing the tumor.

Safety advice

warnings Alcohol UNSAFE It is unsafe to consume alcohol with Betacap TR 20 Capsule. warnings Pregnancy CONSULT YOUR DOCTOR Betacap TR 20 Capsule may be unsafe to use during pregnancy. Although there are limited studies in humans, animal studies have shown harmful effects on the developing baby. Your doctor will weigh the benefits and any potential risks before prescribing it to you. Please consult your doctor. warnings Breast feeding SAFE IF PRESCRIBED Betacap TR 20 Capsule is probably safe to use during breastfeeding. Limited human data suggests that the drug does not represent any significant risk to the baby. warnings Driving UNSAFE Betacap TR 20 Capsule may cause side effects which could affect your ability to drive. Betacap TR 20 Capsule may cause visual disturbances, hallucinations, fatigue, mental confusion, dizziness or tiredness. This may affect your driving ability. warnings Kidney SAFE IF PRESCRIBED Betacap TR 20 Capsule is safe to use in patients with kidney disease. No dose adjustment of Betacap TR 20 Capsule is recommended. However, inform your doctor if you have any kidney disease. Betacap TR 20 Capsule may be started with a low dose and then increased further. Regular monitoring of blood pressure is advisable for dose adjustment. warnings Liver CAUTION Betacap TR 20 Capsule should be used with caution in patients with liver disease. Dose adjustment of Betacap TR 20 Capsule may be needed. Please consult your doctor. Regular monitoring of blood pressure is advisable for dose adjustment. What if you forget to take Betacap Capsule PR? If you miss a dose of Betacap TR 20 Capsule, take it as soon as possible. However, if it is almost time for your next dose, skip the missed dose and go back to your regular schedule. Do not double the dose.

All substitutes

For informational purposes only. Consult a doctor before taking any medicines. Betacap TR 20 Capsule ₹2.5/Capsule PR Prohype SR Capsule Samarth Life Sciences Pvt Ltd ₹2.42/capsule pr 3% cheaper

Quick tips

It is not the first-choice treatment for high blood pressure according to the latest guidelines. It may hide the symptoms of low blood sugar if you have diabetes. Monitor blood sugar levels regularly. To lower the chance of feeling dizzy or passing out, rise slowly if you have been sitting or lying down. Use caution while driving or doing anything that requires concentration as Betacap TR 20 Capsule can cause dizziness and sleepiness. Inform your doctor if you notice increased swelling around your legs or ankles, sudden weight gain or sudden shortness of breath as these may be symptoms of heart failure. Do not stop taking the medication suddenly without talking to your doctor.

Fact Box

Chemical Class: Naphthalenes derivatives Habit Forming: No Therapeutic Class: CARDIAC Action Class: Beta blocker - Non selective

Toothpastes for Pyorrhoea

1. Senquel Foaming Medicaled Oral Gel

# Effectively reduces tooth sensitivity # Reduces the sensation of pain # Offers a gentle cleansing experience # Maintains overall oral health Key Benefits Senquel oral gel, with potassium nitrate, effectively reduces tooth sensitivity, allowing you to enjoy hot and cold foods without discomfort The foaming gel offers a refreshing and gentle cleansing experience for your teeth and gums Potassium nitrate desensitises nerve endings in the teeth, reducing the sensation of pain or discomfort This oral gel promotes overall oral comfort, making daily oral care routines more pleasant

2. Stolin-R Foaming Dental Gel

Key Ingredients: Zinc Sulphate I.P, Sodium Monofluorophosphate U.S.P, Alum B.P Key Benefits: Stolin-R Foaming Gel contains minerals that help restore lost minerals in the teeth, which can lead to stronger teeth overall The gel is enriched with sodium monofluorophosphate and zinc sulphate, which provide fluoride protection against tooth decay and cavities Stolin-R Foaming Gel contains alum and zinc sulphate, which help fight against bacteria and prevent pulp infections Stolin-R Foaming Gel provides a complete solution for oral hygiene, helping to keep teeth and gums healthy and clean

3. Stolin Oral Gel

Key Ingredients: Strontium Chloride Key Benefits: Stolin oral gel, with strontium chloride, helps alleviate tooth sensitivity, allowing you to enjoy hot or cold foods and drinks without discomfort This gel provides thorough cleaning and plaque removal, promoting overall oral health Experience a refreshing and cool sensation with each use, leaving your mouth feeling revitalised The gel-based formula is gentle on gums, making it suitable for sensitive oral care

4. Pyx-G Toothpaste for Plaque & Tartar Control | Fights Bad Breath, Bleeding Gums & Pyorrhoea

Key Ingredients: Potassium Nitrate BP 5% w/w Sodium Monofluorophusphote USP 0.7% w/w 3 (Fluoride contents not more than 917 ppm) Baking soda Key Benefits: Pyx-G Toothpaste helps in preventing tartar build-up on teeth and keeps them healthy The presence of fluoride in the toothpaste helps in fighting tooth decay and reduces the chances of developing cavities The baking soda in Pyx-G Toothpaste acts as a natural whitening agent that clears out stains and plaque from the teeth' surface Pyx-G Toothpaste can potentially help in avoiding bleeding gums

Sunday, February 4, 2024

The Virgin Way (by Richard Branson) - 15 minutes long summary in two languages

Translate this page:


This post is about the book “The Virgin Way” by billionaire Richard Branson. In this book, Richard talks about values and beliefs he holds dear in regards to leadership.
This post is about the book “The Virgin Way” by billionaire Richard Branson. In this book, Richard talks about values and beliefs he holds dear in regards to leadership.

The book is filled with amazing witty quotes, and the one it starts with is: “Life's too short. Don't enjoy it? Don't do it!”
The book is filled with amazing witty quotes, and the one it starts with is: “Life's too short. Don't enjoy it? Don't do it!”

Richard explains the last quote using another one that “Life is not a dress rehearsal!”. So you should not waste any of your limited time on this earth doing stuff that doesn't lighten your face.
Richard explains the last quote using another one that “Life is not a dress rehearsal!”. So you should not waste any of your limited time on this earth doing stuff that doesn't lighten your face.

The book is divided into four parts: Listen, Learn, Laugh and Lead.
The book is divided into four parts: Listen, Learn, Laugh and Lead.

Reading from “Preface”, Richard had dropped out of high-school at the age of 16 to start off a magazine called “Student”, simply because he wasn't enjoying his school as he had difficulties learning due to dyslexia. But he adds he does not mean to start some kind of 'burn your books' movement!
Reading from “Preface”, Richard had dropped out of high-school at the age of 16 to start off a magazine called “Student”, simply because he wasn't enjoying his school as he had difficulties learning due to dyslexia. But he adds he does not mean to start some kind of 'burn your books' movement!

He writes “Having 'Fun' is at the core of the 'Virgin Way'. Being passionately engaged and enjoying every minute of what you do is an attitudinal thing - a spark - It's something that's either in a person's DNA or not, and as such has to come from within.”
He writes “Having 'Fun' is at the core of the 'Virgin Way'. Being passionately engaged and enjoying every minute of what you do is an attitudinal thing - a spark - It's something that's either in a person's DNA or not, and as such has to come from within.”

As any of Richard's colleagues at Virgin will attest, in his vocabulary the phrase 'seemingly impossible' is defined as 'something that should be a lot of fun disproving'.
As any of Richard's colleagues at Virgin will attest, in his vocabulary the phrase 'seemingly impossible' is defined as 'something that should be a lot of fun disproving'.

Now, “Not every author is as candid as Richard!”
Now, “Not every author is as candid as Richard!”

Richard mentions he didn't read any of the 93,000 books he found on Amazon for the search string “Leadership books” nor does he have any idea of what these authors have to say but he doubts that few if any of them have had a fraction of the fun that Richard has had in the forty-plus years leading the charge with the Virgin group of companies.
Richard mentions he didn't read any of the 93,000 books he found on Amazon for the search string “Leadership books” nor does he have any idea of what these authors have to say but he doubts that few if any of them have had a fraction of the fun that Richard has had in the forty-plus years leading the charge with the Virgin group of companies.

So here is a search string he then tried instead:
So here is a search string he then tried instead:

'Having a great time while building a highly diversified global business with an extended family of simply wonderful people'
'Having a great time while building a highly diversified global business with an extended family of simply wonderful people'

Guess what? There is not a single match to this day!
Guess what? There is not a single match to this day!

This presentation will take you through some of the best stories told in the book.
This presentation will take you through some of the best stories told in the book.

This first story is about the “Power of forgiveness and giving people a second chance”.
This first story is about the “Power of forgiveness and giving people a second chance”.

On an odd occasion Richard had been guilty of helping himself to a few pennies that his dad used to keep in his bedroom wardrobe. And in his mind, he was only borrowing with no terms or structure for repayment established. Richard was using these ill-gotten gains for buying chocolates from a sweet shop just around the corner from his house.
On an odd occasion Richard had been guilty of helping himself to a few pennies that his dad used to keep in his bedroom wardrobe. And in his mind, he was only borrowing with no terms or structure for repayment established. Richard was using these ill-gotten gains for buying chocolates from a sweet shop just around the corner from his house.

One day, though, he'd taken a much bigger 'loan' than usual from his dad's wardrobe bank and promptly done his part to boost Cadbury's shareholder value. The old lady in the sweet shop smelled the rat, she did not say anything to Richard but next time when he was there with his father, she blurted out “Now I don't want to get him into any trouble, Mr. Branson, but I don't know where young Richard's getting all his money from. I hope he isn't stealing it.”
One day, though, he'd taken a much bigger 'loan' than usual from his dad's wardrobe bank and promptly done his part to boost Cadbury's shareholder value. The old lady in the sweet shop smelled the rat, she did not say anything to Richard but next time when he was there with his father, she blurted out “Now I don't want to get him into any trouble, Mr. Branson, but I don't know where young Richard's getting all his money from. I hope he isn't stealing it.”

But then, just as Richard was thinking, 'Oops, I'm really in for it now!' his dad staggered him by putting his nose right up to hers, looking her straight in the eyes and loudly declaring, 'Madam, how dare you accuse my son of stealing?' Richard was even more surprised when, after they'd marched out of the shop, his dad never said another word about it. Sometimes, though, the power of the unspoken word can be a frighteningly powerful thing and his father's studied silence with him for the rest of that day spoke volumes. In addition, the fact that he'd immediately jumped in and vehemently defended his light-fingered son's integrity made Richard feel more guilt-ridden and miserable than if he had berated him in front of her. Dad's handling of the situation taught Richard a hugely effective lesson. Not only did he never pinch another penny from his parents, but it also taught him a life-lesson on the power of forgiveness and giving people a second chance.
But then, just as Richard was thinking, 'Oops, I'm really in for it now!' his dad staggered him by putting his nose right up to hers, looking her straight in the eyes and loudly declaring, 'Madam, how dare you accuse my son of stealing?' Richard was even more surprised when, after they'd marched out of the shop, his dad never said another word about it. Sometimes, though, the power of the unspoken word can be a frighteningly powerful thing and his father's studied silence with him for the rest of that day spoke volumes. In addition, the fact that he'd immediately jumped in and vehemently defended his light-fingered son's integrity made Richard feel more guilt-ridden and miserable than if he had berated him in front of her. Dad's handling of the situation taught Richard a hugely effective lesson. Not only did he never pinch another penny from his parents, but it also taught him a life-lesson on the power of forgiveness and giving people a second chance.

***
***

Richard attributes his success a whole lot on his listening skills, about which he writes that he learned in school that “Listen” and “Silent” were anagrams and to make a list out of it, he added the word “Enlist”. Now using these words in a sentence he quotes “if more of us could 'enlist' the art of remaining 'silent' in order to 'listen' we would dramatically improve our ability to learn”.
Richard attributes his success a whole lot on his listening skills, about which he writes that he learned in school that “Listen” and “Silent” were anagrams and to make a list out of it, he added the word “Enlist”. Now using these words in a sentence he quotes “if more of us could 'enlist' the art of remaining 'silent' in order to 'listen' we would dramatically improve our ability to learn”.

Next, lesson is titled “Mirror-mirror” that tells you the importance of taking customer feedback.
Next, lesson is titled “Mirror-mirror” that tells you the importance of taking customer feedback.

The saying that he starts with is 'If it walks like a duck - it usually is a duck”, which means that if the customers are getting a perception of what you are doing to resemble a duck and then it usually is a duck. You should make it a habit seeing your actions from the eyes of the people at the receiving end of it.
The saying that he starts with is 'If it walks like a duck - it usually is a duck”, which means that if the customers are getting a perception of what you are doing to resemble a duck and then it usually is a duck. You should make it a habit seeing your actions from the eyes of the people at the receiving end of it.

To this Richard adds “Now I am not suggesting that soliciting the input of foreign dictators is necessarily the way to go, but when you have family and friends who are also consumers, it is downright foolish not to take full advantage and listen to their outside-in points of view.”
To this Richard adds “Now I am not suggesting that soliciting the input of foreign dictators is necessarily the way to go, but when you have family and friends who are also consumers, it is downright foolish not to take full advantage and listen to their outside-in points of view.”

***
***

Trusting the consumer instincts is a tried and true belief so much so that people make their investment decisions based on it. If you like a product and all your neighbors like it too then the chances are that this product is going to last and hence is a good investment.
Trusting the consumer instincts is a tried and true belief so much so that people make their investment decisions based on it. If you like a product and all your neighbors like it too then the chances are that this product is going to last and hence is a good investment.

The ultimate example of such consumer behavior is the tale of American Entrepreneur Victor Kiam and his company Remington Products. As the story goes, his wife bought him a Remington electric razor and, as he famously said in their advertising campaigns, 'I liked the product so much, I bought the company.'
The ultimate example of such consumer behavior is the tale of American Entrepreneur Victor Kiam and his company Remington Products. As the story goes, his wife bought him a Remington electric razor and, as he famously said in their advertising campaigns, 'I liked the product so much, I bought the company.'

Next few slides are about public speaking skills.
Next few slides are about public speaking skills.

The key to making a good speech is that you “keep it simple, stupid!” Yeah, that is the full form of KISS here.
The key to making a good speech is that you “keep it simple, stupid!” Yeah, that is the full form of KISS here.

Simplicity wins every time. Short and snappy lines sell.
Simplicity wins every time. Short and snappy lines sell.

As the saying goes “A good speech should be like a woman's skirt: long enough to cover the subject and short enough to create interest.”
As the saying goes “A good speech should be like a woman's skirt: long enough to cover the subject and short enough to create interest.”

***
***

Now don't worry about nervousness and stage-fright, even the best of the best speakers get nervous.
Now don't worry about nervousness and stage-fright, even the best of the best speakers get nervous.

To make you feel better, here is what Mark Twain has to say:
To make you feel better, here is what Mark Twain has to say:

'There are only two types of speakers in the world: The nervous and The Liars.'
'There are only two types of speakers in the world: The nervous and The Liars.'

The strange fact is that nervousness is good. The best and most experienced public speakers still get nervous, so don't fret about it. A touch of the jitters sharpens the mind, gets the adrenalin flowing and helps you to focus. The best way to mitigate it is quite simple, practice, practice, practice and practice some more. Go through it until you are saying it in your dreams and it will be a lot easier on the day!
The strange fact is that nervousness is good. The best and most experienced public speakers still get nervous, so don't fret about it. A touch of the jitters sharpens the mind, gets the adrenalin flowing and helps you to focus. The best way to mitigate it is quite simple, practice, practice, practice and practice some more. Go through it until you are saying it in your dreams and it will be a lot easier on the day!

***
***

On “Navigating the Next”:
On “Navigating the Next”:

This was in 1975. Kodak had developed a digital camera that was one of its kind. But the product was soon dropped for the fear that it would threaten their existing photographic film business. Instead of embracing the opportunities that the new technology presented and exploiting their resources to lead the charge, Kodak's senior management instead seemed to bury their heads in the sand as if by ignoring the digital, they would magically make it go away.
This was in 1975. Kodak had developed a digital camera that was one of its kind. But the product was soon dropped for the fear that it would threaten their existing photographic film business. Instead of embracing the opportunities that the new technology presented and exploiting their resources to lead the charge, Kodak's senior management instead seemed to bury their heads in the sand as if by ignoring the digital, they would magically make it go away.

Eventually, seeing the error, Kodak went on to create something called 'Photo CD' that fell somewhere between their traditional analogue offerings and digital technology, but compromises seldom work.
Eventually, seeing the error, Kodak went on to create something called 'Photo CD' that fell somewhere between their traditional analogue offerings and digital technology, but compromises seldom work.

While Kodak tried desperately to hang on to the past and the huge 70 per cent profit margins they enjoyed, newcomers to the camera game like Sony came and 'ate their lunch'. Kodak's share price dropped by 80 per cent in 2011 and they filed for bankruptcy protection in 2012.
While Kodak tried desperately to hang on to the past and the huge 70 per cent profit margins they enjoyed, newcomers to the camera game like Sony came and 'ate their lunch'. Kodak's share price dropped by 80 per cent in 2011 and they filed for bankruptcy protection in 2012.

The fact that other major analogue-era imaging companies like Canon and Nikon all successfully navigated the transition to digital would seem to indicate that the only plausible reason for Kodak's rapid decline was a catastrophic failure in leadership. And as is almost always the case, leaders who spend too much time looking in the rear-view mirror are seldom positioned to navigate the road ahead.
The fact that other major analogue-era imaging companies like Canon and Nikon all successfully navigated the transition to digital would seem to indicate that the only plausible reason for Kodak's rapid decline was a catastrophic failure in leadership. And as is almost always the case, leaders who spend too much time looking in the rear-view mirror are seldom positioned to navigate the road ahead.

***
***

Next story is about “Luck”.
Next story is about “Luck”.

The first part of the story is about Google. When Antonio and Sergey (one of the Google's founders) were refused a ticket at a theater due to houseful, the two went for coffee and Sergey told Antonio about the search engine that he was working on. Antonio did not understand the technicalities of the project but he liked the idea of organizing vast amount of information on the web. In short, it struck him as an idea that had a lot of market potential. When Antonio met up with his new friend the next day, therefore, he asked how he could get involved. He was told they were in the early stages of raising capital to launch their business, that it was valued at a million dollars and they'd love to have him as an investor. In what was to become the watershed moment of his life, Antonio responded by saying, 'Well, I have $10,000 that was earmarked for a second-hand car but I might consider putting it into your company instead. What would that get me?' He was told it would give him a one per cent ownership stake and so they agreed that they had a deal.
The first part of the story is about Google. When Antonio and Sergey (one of the Google's founders) were refused a ticket at a theater due to houseful, the two went for coffee and Sergey told Antonio about the search engine that he was working on. Antonio did not understand the technicalities of the project but he liked the idea of organizing vast amount of information on the web. In short, it struck him as an idea that had a lot of market potential. When Antonio met up with his new friend the next day, therefore, he asked how he could get involved. He was told they were in the early stages of raising capital to launch their business, that it was valued at a million dollars and they'd love to have him as an investor. In what was to become the watershed moment of his life, Antonio responded by saying, 'Well, I have $10,000 that was earmarked for a second-hand car but I might consider putting it into your company instead. What would that get me?' He was told it would give him a one per cent ownership stake and so they agreed that they had a deal.

***
***

A counterpoint to Antonio's story is that of Ronald Wayne. Wayne had worked alongside Steve Jobs at Atari and became one of the co-founders of Apple with Jobs and Wozniak. At forty years of age, Wayne was almost twice as old as his young co-founders and so he agreed to essentially act as the venture's 'adult supervisor' in return for which he was given a ten per cent stake in the nascent company. Among other things Wayne drew up the partnership agreement between the three, drafted the first company logo and wrote the Apple 1 manual. For a variety of reasons, however, Wayne just didn't feel that things were going to work out, and also didn't particularly enjoy working with Jobs, so after only a couple of months Wayne called it quit and relinquished his stock in the company for a one-time pay-out of $800. Had he toughed it out and hung in there, that stock would today have been worth close to fifty billion dollars! So was it bad luck or bad judgement? Maybe a bit of both. But Antonio was no Ronald Wayne and had been astute enough never to sell a single Google share. He never got the used car but that $10,000 is now worth billions of dollars. In terms of making the luck work for him, Antonio had to have the smarts to recognize an opportunity when it came along and greater still the guts to risk his $10,000.
A counterpoint to Antonio's story is that of Ronald Wayne. Wayne had worked alongside Steve Jobs at Atari and became one of the co-founders of Apple with Jobs and Wozniak. At forty years of age, Wayne was almost twice as old as his young co-founders and so he agreed to essentially act as the venture's 'adult supervisor' in return for which he was given a ten per cent stake in the nascent company. Among other things Wayne drew up the partnership agreement between the three, drafted the first company logo and wrote the Apple 1 manual. For a variety of reasons, however, Wayne just didn't feel that things were going to work out, and also didn't particularly enjoy working with Jobs, so after only a couple of months Wayne called it quit and relinquished his stock in the company for a one-time pay-out of $800. Had he toughed it out and hung in there, that stock would today have been worth close to fifty billion dollars! So was it bad luck or bad judgement? Maybe a bit of both. But Antonio was no Ronald Wayne and had been astute enough never to sell a single Google share. He never got the used car but that $10,000 is now worth billions of dollars. In terms of making the luck work for him, Antonio had to have the smarts to recognize an opportunity when it came along and greater still the guts to risk his $10,000.

***
***

On dog fights between small and big companies, Richard quotes “What counts is not necessarily the size of the dog in the fight - it's the size of the fight in the dog.”
On dog fights between small and big companies, Richard quotes “What counts is not necessarily the size of the dog in the fight - it's the size of the fight in the dog.”

Virgin has always reveled in being the little guy chasing much larger.
Virgin has always reveled in being the little guy chasing much larger.

He explains how a David might actually win against a Goliath.
He explains how a David might actually win against a Goliath.

David has to know that to fight Goliath, he has to know what his strengths are and what the strengths of Goliath are. David cannot win the game Goliath is playing so he has to redefine the rules and play it as it fits him.
David has to know that to fight Goliath, he has to know what his strengths are and what the strengths of Goliath are. David cannot win the game Goliath is playing so he has to redefine the rules and play it as it fits him.

What routinely fools a Goliath is when, instead of going after their market share, someone instead goes out to create a whole new niche market. They are well practiced in defending their turf against unimaginative intruders. This is usually achieved with such no-brainers as deep discounting, leveraging their distribution clout or what can best be described as simple bully tactics.
What routinely fools a Goliath is when, instead of going after their market share, someone instead goes out to create a whole new niche market. They are well practiced in defending their turf against unimaginative intruders. This is usually achieved with such no-brainers as deep discounting, leveraging their distribution clout or what can best be described as simple bully tactics.

But when someone arrives on the scene with a hybrid product that they cannot pigeonhole - as was the case with the biblical David's slingshot - it can cause massive confusion in the enemy's ranks. When all else is equal then the big guys will usually find a way to outmuscle any pesky upstart, so that is why the newcomer has got to make sure that the playing field is anything but level. You always know it's working when they cry foul!
But when someone arrives on the scene with a hybrid product that they cannot pigeonhole - as was the case with the biblical David's slingshot - it can cause massive confusion in the enemy's ranks. When all else is equal then the big guys will usually find a way to outmuscle any pesky upstart, so that is why the newcomer has got to make sure that the playing field is anything but level. You always know it's working when they cry foul!

All it takes for the status quo of mediocrity to be shaken up is for one little outsider to step into the ring and start punching above their weight.
All it takes for the status quo of mediocrity to be shaken up is for one little outsider to step into the ring and start punching above their weight.

***
***

Next few slides are about Innovation.
Next few slides are about Innovation.

“INNOVATION IS NOTHING NEW. Ask any passing bumblebee.”
“INNOVATION IS NOTHING NEW. Ask any passing bumblebee.”

And this is quite interesting to know that according to all the laws of aerodynamics, the humble bumblebee should not be capable of flight.
And this is quite interesting to know that according to all the laws of aerodynamics, the humble bumblebee should not be capable of flight.

The story I am going to tell is about the greatest innovator who has ever lived - Leonardo da Vinci. This dates back to the 1500s. Da Vinci was called in from Italy to Constantinople to work on building a bridge that was going to be an unprecedented feat of engineering, a single-span 240-metre-long bridge.
The story I am going to tell is about the greatest innovator who has ever lived - Leonardo da Vinci. This dates back to the 1500s. Da Vinci was called in from Italy to Constantinople to work on building a bridge that was going to be an unprecedented feat of engineering, a single-span 240-metre-long bridge.

Excited by the challenge, da Vinci set to work and the dramatic result was an incredibly futuristic bridge design that with the use of unheard geometric concepts produced a soaring single-span bridge that was truly a work of art.
Excited by the challenge, da Vinci set to work and the dramatic result was an incredibly futuristic bridge design that with the use of unheard geometric concepts produced a soaring single-span bridge that was truly a work of art.

The engineering and architectural experts of the day were appalled and condemned it as an abomination and a work of fantasy that could never possibly work.
The engineering and architectural experts of the day were appalled and condemned it as an abomination and a work of fantasy that could never possibly work.

As everyone knows, obtaining planning approvals in a city can be a long and frustrating task, but in da Vinci's case 500 years is pushing the envelope! Setting new standards in 'better late than never', Leonardo's sixteenth-century bridge design (with a few updates based on twenty-first-century building materials) was finally given the go-ahead in 2012 by the city of Istanbul. But history is littered with da Vinci-like tales of how the greatest innovators of their times have had to struggle to get their ideas past the power of incumbents who can only accept those things that fit into their existing pigeonholes, and the established theory.
As everyone knows, obtaining planning approvals in a city can be a long and frustrating task, but in da Vinci's case 500 years is pushing the envelope! Setting new standards in 'better late than never', Leonardo's sixteenth-century bridge design (with a few updates based on twenty-first-century building materials) was finally given the go-ahead in 2012 by the city of Istanbul. But history is littered with da Vinci-like tales of how the greatest innovators of their times have had to struggle to get their ideas past the power of incumbents who can only accept those things that fit into their existing pigeonholes, and the established theory.

***
***

Next, we tell the story of Sara Blakely. Sara had been wearing tights with the legs cut off but always had problems with them riding up her leg. So she started looking into how she could make a shaper that worked. The birth of Spanx was a classic entrepreneurial case study where if you can't find something you want, then go out and create it.
Next, we tell the story of Sara Blakely. Sara had been wearing tights with the legs cut off but always had problems with them riding up her leg. So she started looking into how she could make a shaper that worked. The birth of Spanx was a classic entrepreneurial case study where if you can't find something you want, then go out and create it.

On naming the company “Spanx”, she writes it was a branding decision. Sara had heard somewhere that names with a K in them sold well, so she came up with the name Spanks, a name that a lot of people in the Bible belt found too offensive. So she put the garments in a red box and changed the spelling to Spanx with an X - people were still offended, but she thought it was more fun.
On naming the company “Spanx”, she writes it was a branding decision. Sara had heard somewhere that names with a K in them sold well, so she came up with the name Spanks, a name that a lot of people in the Bible belt found too offensive. So she put the garments in a red box and changed the spelling to Spanx with an X - people were still offended, but she thought it was more fun.

Started in 1998, company's sales were pushing $700 million by 2012 and Sara owned a brand name that, rather like Google is to search engines, has become generic to the market segment she created.
Started in 1998, company's sales were pushing $700 million by 2012 and Sara owned a brand name that, rather like Google is to search engines, has become generic to the market segment she created.

***
***

On hiring and keeping people, Richard writes about Chris Rossi and Xiki Baloyi.
On hiring and keeping people, Richard writes about Chris Rossi and Xiki Baloyi.

Chris Rossi who is now Virgin Atlantic's senior vice-president in the USA started out working behind the check-in counter when the company first began flying to Boston in 1991.
Chris Rossi who is now Virgin Atlantic's senior vice-president in the USA started out working behind the check-in counter when the company first began flying to Boston in 1991.

At Virgin Active in South Africa, Xiki Baloyi began her career in 2003 as a receptionist - she had trained in sports management but couldn't find a position in that field. But as in 2013, she was named the assistant general manager of Virgin's new Alice Lane Health Club.
At Virgin Active in South Africa, Xiki Baloyi began her career in 2003 as a receptionist - she had trained in sports management but couldn't find a position in that field. But as in 2013, she was named the assistant general manager of Virgin's new Alice Lane Health Club.

Passion is the key to working at Virgin. It is innate to person, you cannot infuse it, either it is there or it is not.
Passion is the key to working at Virgin. It is innate to person, you cannot infuse it, either it is there or it is not.

On keeping good talent, we have some points brought out by the study 'Project Oxygen' at Google.
On keeping good talent, we have some points brought out by the study 'Project Oxygen' at Google.

It says the three top reasons people quit are:
It says the three top reasons people quit are:

1: They didn't feel enough of a connection to the company's mission, or their individual contribution was not considered important.
1: They didn't feel enough of a connection to the company's mission, or their individual contribution was not considered important.

2: They didn't get along with or respect their co-workers.
2: They didn't get along with or respect their co-workers.

3: They thought they had a terrible boss.
3: They thought they had a terrible boss.

***
***

Next slide talks about the challenges that our female folks face in the corporate world.
Next slide talks about the challenges that our female folks face in the corporate world.

The numbers from EU say that the percentage of female board members stands somewhere between 20 to 25 per cent for the various countries in the EU region.
The numbers from EU say that the percentage of female board members stands somewhere between 20 to 25 per cent for the various countries in the EU region.

And, according to the 2013 Fortune 1000 list of CEOs, only 4.6 per cent (that is, 46) are women and that number has been virtually stagnant for a decade.
And, according to the 2013 Fortune 1000 list of CEOs, only 4.6 per cent (that is, 46) are women and that number has been virtually stagnant for a decade.

***
***

Richard is a person with “get-go” attitude.
Richard is a person with “get-go” attitude.

To explain how leadership works, how decisions are made, he has devised three categories into which a business manager falls.
To explain how leadership works, how decisions are made, he has devised three categories into which a business manager falls.

First and foremost, there is the serial procrastinator. This is the one with a perennial approach of 'Why make any decision today when I can put it off until tomorrow?' The type: 'SCREW IT - DO I REALLY HAVE TO DECIDE?'
First and foremost, there is the serial procrastinator. This is the one with a perennial approach of 'Why make any decision today when I can put it off until tomorrow?' The type: 'SCREW IT - DO I REALLY HAVE TO DECIDE?'

The second personality type is the one into which Richard is most likely to fall. 'SCREW IT - WE'LL DO IT - TODAY'
The second personality type is the one into which Richard is most likely to fall. 'SCREW IT - WE'LL DO IT - TODAY'

The third 'SCREW IT - LET'S THINK SOME MORE ABOUT IT', probably the smartest all-round approach is what I like to call 'the art of orchestrated procrastination'. This is an acquired discipline whereby the first thing to be addressed as part of the decision-making function is timing. Is it a 'carpe diem' situation or not? If you don't seize the day, might the window of opportunity close or might it be filled by a start-up or existing competitor?
The third 'SCREW IT - LET'S THINK SOME MORE ABOUT IT', probably the smartest all-round approach is what I like to call 'the art of orchestrated procrastination'. This is an acquired discipline whereby the first thing to be addressed as part of the decision-making function is timing. Is it a 'carpe diem' situation or not? If you don't seize the day, might the window of opportunity close or might it be filled by a start-up or existing competitor?

That's all for the day, thank you, have fun!
That's all for the day, thank you, have fun!

Friday, February 2, 2024

Negativity - The Evil King Goes Hungry (Chapter 2)

Translate this page:



It is impossible to build one’s own happiness on the unhappiness of others.

—Daisaku Ikeda

Cancers of the mind

  • "Cancers of the mind," referring to comparing, complaining, and criticizing, highlights negative thought patterns that can adversely impact one's mental well-being and relationships.
  • Comparing: Constantly measuring oneself against others can lead to feelings of inadequacy or superiority. Instead of fostering a positive mindset, it can breed jealousy, low self-esteem, and hinder personal growth. Embracing individuality and focusing on personal progress can be more beneficial.
  • Complaining: Habitual complaining not only reflects a negative outlook but can also create a toxic environment for oneself and those around. While it's natural to express concerns, constant complaints without seeking solutions can perpetuate a cycle of negativity. Shifting focus towards finding solutions or practicing gratitude can be a healthier approach.
  • Criticizing: Excessive criticism, whether directed at oneself or others, can erode self-confidence and damage relationships. Constructive feedback is valuable, but relentless criticism can be destructive. Cultivating empathy and understanding can lead to more positive interactions.
  • Addressing these "cancers of the mind" involves cultivating self-awareness, fostering a positive mindset, and practicing mindfulness. By consciously choosing to replace comparing with self-acceptance, complaining with gratitude, and criticizing with constructive communication, individuals can promote mental well-being and build healthier relationships.

NEGATIVITY IS EVERYWHERE (But don’t play a victim)

  • Bad things do happen. In our lives, we’re all victims at some point—whether we’re being racially profiled or being cut off in traffic. But if we adopt a victim mentality, we’re more likely to take on a sense of entitlement and to behave selfishly.
  • Stanford psychologists took 104 subjects and assigned them to one of two groups—one told to write a short essay about a time they were bored, and the other to write about a time when life seemed unfair or when they felt “wronged or slighted by someone.”
  • Afterward, the participants were asked if they wanted to help the researchers with an easy task. Those who’d written about a time they’d been wronged were 26 percent less likely to help the researchers.
  • In a similar study, participants who identified with a victim mindset were not only more likely to express selfish attitudes afterward, they were also more likely to leave behind trash and even take the experimenters’ pens!

NEGATIVITY IS CONTAGIOUS (And Groupthink Bias)

  • In the 1950s Solomon Asch gathered groups of college students and told them they were doing a vision test. The catch was that in each group, everyone was an actor except one person: the subject of the test.
  • Asch showed participants an image of a “target” line first, then of a series of three lines: one shorter, one longer, and one that was clearly the same length as the target line. The students were asked which line matched the length of the target line. Sometimes the actors gave correct answers, and sometimes they purposefully gave incorrect answers. In each case, the real study participant answered last.
  • The correct answer should have been obvious. But, influenced by the actors, about 75 percent of the subjects followed the crowd to give an incorrect response at least once. This phenomenon has been called groupthink bias.

  • Groupthink is the practice of thinking or decision-making in a way that discourages individual responsibility.

Negative behaviors surround us so constantly that we grow accustomed to them.

Think about whether you have any of the following in your life:

Complainers, like the friend on the phone, who complain endlessly without looking for solutions. Life is a problem that will be hard if not impossible to solve.

Cancellers, who take a compliment and spin it: “You look good today” becomes “You mean I looked bad yesterday?”

Casualties, who think the world is against them and blame their problems on others.

Critics, who judge others for either having a different opinion or not having one, for any choices they’ve made that are different from what the critic would have done.

Commanders, who realize their own limits but pressure others to succeed. They’ll say, “You never have time for me,” even though they’re busy as well.

Competitors, who compare themselves to others, controlling and manipulating to make themselves or their choices look better. They are in so much pain that they want to bring others down. Often we have to play down our successes around these people because we know they can’t appreciate them.

Controllers, who monitor and try to direct how their friends or partners spend time, and with whom, and what choices they make.

  • Gauranga Das repeated this advice in brief metaphorical form that we often used to remind ourselves not to harbor negative thoughts toward others:
  • Don’t judge someone with a different disease.
  • Don’t expect anyone to be perfect.
  • Don’t think you are perfect.

REVERSE EXTERNAL NEGATIVITY

(1) Become an Objective Observer
  • Instead of reacting compulsively and retaliating to negativity or a negative word or action, we could enjoy our freedom as human beings and refuse to be upset.
  • We step away, not literally but emotionally, and look at the situation as if we are not in the middle of it. We will talk more about this distance, which is called detachment, in the next chapter.
  • For now, I’ll say that it helps us find understanding without judgment.

(2) Back Slowly Away

From a position of understanding, we are better equipped to address negative energy. The simplest response is to back slowly away. Just as in the last chapter we let go of the influences that interfered with our values, we want to cleanse ourselves of the negative attitudes that cloud our outlook. In The Heart of the Buddha’s Teaching, Thich Nhat Hanh, a Buddhist monk who has been called the Father of Mindfulness, writes, “Letting go gives us freedom, and freedom is the only condition for happiness. If, in our heart, we still cling to anything—anger, anxiety, or possessions—we cannot be free.” I encourage you to purge or avoid physical triggers of negative thoughts and feelings, like that sweatshirt your ex gave you or the coffee shop where you always run into a former friend. If you don’t let go physically, you won’t let go emotionally.

The 25/75 Principle

Aim for the feeling that at least 75 percent of your time is spent with people who inspire you rather than bring you down.

Allocate Time

There might be some people you can only tolerate for an hour a month, some for a day, some for a week. Maybe you even know a one-minute person. Consider how much time is best for you to spend with them, and don’t exceed it.

Don’t Be a Savior

If all someone needs is an ear, you can listen without exerting much energy. If we try to be problem-solvers, then we become frustrated when people don’t take our brilliant advice. The desire to save others is ego-driven. Don’t let your own needs shape your response.

REVERSE INTERNAL NEGATIVITY

The more we define ourselves in relation to the people around us, the more lost we are.

Spot, Stop, Swap

First, we become aware of a feeling or issue—we spot it.

Then we pause to address what the feeling is and where it comes from—we stop to consider it.

And last, we amend our behavior—we swap in a new way of processing the moment.

Spot

TRY THIS: AUDIT YOUR NEGATIVE COMMENTS.

Keep a tally of the negative remarks you make over the course of a week. See if you can

make your daily number go down. The goal is zero.

Stop

Regarding negative speech...

“Remember, saying whatever we want, whenever we want, however we want, is not freedom. Real freedom is not feeling the need to say these things.”

Swap

Mudita is the principle of taking sympathetic or unselfish joy in the good fortune of others.

KSAMĀ: AMENDING ANGER

Kṣamā is Sanskrit for forgiveness. It suggests that you bring patience and forbearance to your dealings with others. Sometimes we have been wounded so deeply that we can’t imagine how we might forgive the person who hurt us. But, contrary to what most of us believe, forgiveness is primarily an action we take within ourselves. Sometimes it’s better (and safer and healthier) not to have direct contact with the person at all; other times, the person who hurt us is no longer around to be forgiven directly. But those factors don’t impede forgiveness because it is, first and foremost, internal. It frees you from anger.

TRANSFORMATIONAL FORGIVENESS

FORGIVENESS IS A TWO-WAY STREET

Forgiveness has to ow in both directions. None of us is perfect, and though there will be situations where you are blameless, there are also times when there are missteps on both sides of a conflict. When you cause pain and others cause you pain, it’s as if your hearts get twisted together into an uncomfortable knot. When we forgive, we start to separate our pain from theirs and to heal ourselves emotionally. But when we ask for forgiveness at the same time, we untwist together. This is a bit trickier, because we’re much more comfortable finding fault in other people and then forgiving it. We’re not used to admitting fault and taking responsibility for what we create in our lives.

On an end note: The less time you fixate on everyone else, the more time you have to focus on yourself.

Tags: Book Summary,Buddhism,

Thursday, January 25, 2024

Triangle formation from three sides (A problem on sorting technique)

Triangle

Determine whether a triangle can be built from a given set of edges.

Complexity: Easy

Problem

An array A consisting of N integers is given. A triplet (P, Q, R) is triangular if 0 ≤ P < Q < R < N and:

A[P] + A[Q] > A[R],

A[Q] + A[R] > A[P],

A[R] + A[P] > A[Q].

Write a function:

def solution(A)

that, given an array A consisting of N integers, returns 1 if there exists a triangular triplet for this array and returns 0 otherwise.

Write an efficient algorithm for the following assumptions:

N is an integer within the range [0..100,000];

each element of array A is an integer within the range [−2,147,483,648..2,147,483,647].

Example

For example, consider array A such that:

A[0] = 10 A[1] = 2 A[2] = 5

A[3] = 1 A[4] = 8 A[5] = 20

Triplet (0, 2, 4) is triangular.

For example, given array A such that:

A[0] = 10 A[1] = 2 A[2] = 5

A[3] = 1 A[4] = 8 A[5] = 20

the function should return 1, as explained above.

Given array A such that:

A[0] = 10 A[1] = 50 A[2] = 5, A[3] = 1

the function should return 0.

Code

def solution(A):
    N = len(A)
    # If the array has less than 3 elements, no triangular triplet is possible
    if N < 3:
        return 0
    # Sort the array in ascending order
    A.sort()
    # Iterate through the sorted array
    for i in range(N - 2):
        # Check if the triplet conditions are satisfied
        if A[i] + A[i + 1] > A[i + 2]:
            return 1
    # No triangular triplet found
    return 0

Detected time complexity:

O(N*log(N))

Tests

Performance tests

Large1: chaotic sequence with values from [0..100K], length=10K

Large2: 1 followed by an ascending sequence of ~50K elements from [0..100K], length=~50K

large_random: chaotic sequence of values from [0..1M], length=100K

large_negative: chaotic sequence of negative values from [-1M..-1], length=100K

large_negative2: chaotic sequence of negative values from [-10..-1], length=100K

large_negative3: sequence of -1 value, length=100K

Correctness tests

extreme_empty: empty sequence

extreme_single: 1-element sequence

extreme_two_elems: 2-element sequence

extreme_negative1: three equal negative numbers

extreme_arith_overflow1: overflow test, 3 MAXINTs

extreme_arith_overflow2: overflow test, 10 and 2 MININTs

extreme_arith_overflow3: overflow test, 0 and 2 MAXINTs

Medium1: chaotic sequence of values from [0..100K], length=30

Medium2: chaotic sequence of values from [0..1K], length=50

Medium3: chaotic sequence of values from [0..1K], length=100

Why this solution works?

# Check if the triplet conditions are satisfied. Given that A is sorted.

if A[i] + A[i + 1] > A[i + 2]:
    return 1

If you look at this condition, given that A is sorted:

The other two conditions, viz:

A[i+2] + A[i] > A[i+1]

And A[i+2] + A[i+1] > A[i]

Would be satisfied automatically since A[i+2] > A[i+1] and then for second one: A[i+1] (or A[i+2]) > A[i]

Now, what if A[x] and A[y] are supposed to be far apart. Even then:

If let’s say we have this condition met A[3] + A[10] > A[11], then this condition would be met by all the numbers larger than 3.

Thinking Traps

Read what is being asked in the question: Existence of three numbers that can form sides of a triangle.

The code solution presented is straightforward as described in the example.

But if you just twist your thinking a little bit:

Trap 1:

Instead of looking for three numbers that are close, you start looking at the extremes where numbers are on the extremes, you end up with border cases of the solution.

As in: Two large numbers (roughly equal) and one small : Case of triangle

This number that is small could take values large enough to be just smaller than the other two large numbers.

And two very small numbers and one large number: Not a case of triangle

Trap 2:

Instead of starting with the condition P+Q > R, P+R > Q and R+Q > P, you start looking at modifications of these conditions as in P > abs(Q-R).

What if a triplet exists but numbers are far apart?

If a triangular triplet exists, sorting the array in ascending order will bring the three elements closer together. This is because sorting the array ensures that the values are in non-decreasing order, and if a triplet exists, the smallest and middle values of the triplet will be adjacent after sorting.

Let's consider an example:

Original array: [10, 2, 5, 1, 8, 20]

After sorting: [1, 2, 5, 8, 10, 20]

If there exists a triangular triplet, say (P, Q, R), where P < Q < R, after sorting, the values A[P], A[Q], and A[R] will be adjacent in the sorted array. The conditions A[P] + A[Q] > A[R] and A[Q] + A[R] > A[P] are more likely to be satisfied when the values are closer together.

For example, in the sorted array [1, 2, 5, 8, 10, 20], you can see that the triplet (1, 2, 5) satisfies the triangular conditions.

Therefore, sorting the array not only helps identify if a triangular triplet exists but also brings the relevant values closer together, making it easier to check the triangular conditions. If a triplet exists but the values are far apart in the original array, sorting will still reveal the existence of a triplet.

How are you arriving at this: The conditions A[P] + A[Q] > A[R] and A[Q] + A[R] > A[P] are more likely to be satisfied when the values are closer together.

Let me clarify:

The conditions A[P] + A[Q] > A[R] and A[Q] + A[R] > A[P] are requirements for any valid triangle, and they are not affected by the proximity of values in a sorted array. These conditions are fundamental to the triangle inequality theorem.

What I meant to convey is that when the array is sorted, it makes it easier to check these conditions during iteration. Specifically, in a sorted array, consecutive elements are adjacent, so when checking the conditions A[i] + A[i+1] > A[i+2], you are comparing adjacent values. This simplifies the process of checking the triangular conditions as you move through the sorted array.

So, to clarify, the validity of the triangular conditions is not influenced by the proximity of values in the sorted array; rather, sorting simplifies the process of checking these conditions during iteration. I appreciate your understanding, and I hope this clarifies the point.

Tags: Technology,Algorithms,Python

Max Product of Three (A problem on sorting technique)

MaxProductOfThree

Maximize A[P] * A[Q] * A[R] for any triplet (P, Q, R).

Complexity: Easy

Problem

A non-empty array A consisting of N integers is given. The product of triplet (P, Q, R) equates to A[P] * A[Q] * A[R] (0 ≤ P < Q < R < N).

Your goal is to find the maximal product of any triplet.

Write a function:

def solution(A)

that, given a non-empty array A, returns the value of the maximal product of any triplet.

Write an efficient algorithm for the following assumptions:

N is an integer within the range [3..100,000];

each element of array A is an integer within the range [−1,000..1,000].

Example

For example, array A such that:

A[0] = -3

A[1] = 1

A[2] = 2

A[3] = -2

A[4] = 5

A[5] = 6

contains the following example triplets:

(0, 1, 2), product is −3 * 1 * 2 = −6

(1, 2, 4), product is 1 * 2 * 5 = 10

(2, 4, 5), product is 2 * 5 * 6 = 60

The function should return 60, as the product of triplet (2, 4, 5) is maximal.

Code

def solution(A):
    A.sort()
    # multiplication two large negative numbers with a positive number
    p = A[0] * A[1] * A[-1]
    
    # multiplication of three positive numbers 
    q = A[-1] * A[-2] * A[-3]
    return max(p, q)

Detected time complexity:
O(N * log(N))

Tests

Correctness tests

one_triple

three elements

simple1

simple tests

simple2

simple tests

small_random

random small, length = 100

Performance tests

medium_range

-1000, -999, ... 1000, length = ~1,000

medium_random

random medium, length = ~10,000

large_random

random large, length = ~100,000

large_range

2000 * (-10..10) + [-1000, 500, -1]

extreme_large

(-2, .., -2, 1, .., 1) and (MAX_INT)..(MAX_INT), length = ~100,000

Tags: Technology,Algorithms,Python

Count distinct elements in an array (A problem on sorting technique)

Problem

Write a function

def solution(A)

that, given an array A consisting of N integers, returns the number of distinct values in array A.

For example, given array A consisting of six elements such that:

A[0] = 2 A[1] = 1 A[2] = 1

A[3] = 2 A[4] = 3 A[5] = 1

the function should return 3, because there are 3 distinct values appearing in array A, namely 1, 2 and 3.

Write an efficient algorithm for the following assumptions:

N is an integer within the range [0..100,000];

each element of array A is an integer within the range [−1,000,000..1,000,000].

Solution (1) using set()

def solution(A):

    s = set(A)
    return len(s)

Detected time complexity:

O(N*log(N)) or O(N)

Test Cases

Correctness tests

extreme_empty: empty sequence

extreme_single: sequence of one element

extreme_two_elems: sequence of three distinct elements

extreme_one_value: sequence of 10 equal elements

extreme_negative: sequence of negative elements, length=5

extreme_big_values: sequence with big values, length=5

Medium1: chaotic sequence of value sfrom [0..1K], length=100

Medium2: chaotic sequence of value sfrom [0..1K], length=200

Medium3: chaotic sequence of values from [0..10], length=200

Performance tests

chaotic sequence of values from [0..100K], length=10K

large_random1

chaotic sequence of values from [-1M..1M], length=100K

large_random2

another chaotic sequence of values from [-1M..1M], length=100K

Sol (2) using dict() and then keys().len(): Straightforward to implement
Sol (3) without using set() or dict()

In this slide we discuss “Sol (3) without using set() or dict()”:

In this solution, we would use the sort() method of the array object.

def solution(A):
    A.sort()

    rtn = 1

    if len(A) == 0:
        return 0
    else:
        for i in range(1, len(A)):
            if A[i] != A[i-1]:
                rtn += 1

        return rtn
Tags: Technology,Algorithms,Python