Check if Number is a Sum of Powers of Three | Maths Proof | 3 Ways | Leetcode 1780 |codestorywithMIK

Subscribers:
92,300
Published on ● Video Link: https://www.youtube.com/watch?v=BpotFrERzP4



Duration: 0:00
6,574 views
320


Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A

Hi Everyone, this is the 21st video of our Playlist "Maths : Popular Interview Problems".
Now we will be solving a good Maths problem - Check if Number is a Sum of Powers of Three | Maths Proof | Multiple Approaches | Leetcode 1780 | codestorywithMIK
We will also see with Mathematical Proof and understand the pure maths behind the approach so that even beginners will be able to understand.

Problem Name : Check if Number is a Sum of Powers of Three | Maths Proof | Multiple Approaches | Leetcode 1780 | codestorywithMIK
Company Tags : will update later
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Mathematical/Check if Number is a Sum of Powers of Three.cpp
Leetcode Link : https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three


My DP Concepts Playlist :    • Roadmap for DP | How to Start DP ? | ...  
My Graph Concepts Playlist :    • Graph Concepts & Qns - 1 : Graph will...  
My Segment Tree Concepts Playlist :    • Segment Tree | Introduction | Basics ...  
My Recursion Concepts Playlist :    • Introduction | Recursion Concepts And...  
Trie Playlist -    • Word Search II (Google, Amazon, Meta,...  
Difference Array Technique: Concepts & Qns :    • Introduction | What | How | Differenc...  
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Subscribe to my channel :    / @codestorywithmik  

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝


Video Summary :
1) Using School Maths:
The idea is to find the highest power of 3 that is ≤ n.
Keep subtracting the largest possible power of 3 from n.
If n can be reduced to 0 without using the same power twice, return true; otherwise, return false.

2) Using Ternary Representation:
Convert n to base 3 (ternary).
If any digit in the ternary representation is 2, return false (since we can only use 0 or 1 powers of 3).
Otherwise, return true.

3) Using Take and Not Take (Recursion):
Explore two choices at each step: either take the current power of 3 or skip it.
If n becomes 0 in any recursive path, return true.
If no valid combination is found, return false.
This approach mimics the subset sum problem and is less efficient.


✨ Timelines✨
00:00 - Introduction
0:24 - Motivation
0:41 - Problem Explanation
2:09 - Approach-1 (School Maths)
13:57 - Coding Approach-1
16:13 - Approach-2 with Maths Proof (Ternary Representation)
19:18 - How to do Binary Represenataion
22:57 - How to do Ternary Represenataion
33:05 - Coding Approach-2
33:38 - Approach-3 (Simple Recursion)
39:39 - Coding Approach-3

#MIK #mik #Mik
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik




Other Videos By codestorywithMIK


2025-03-12Zero Array Transformation II | Brute Force | Better | Leetcode 3356 | codestorywithMIK
2025-03-11Maximum Count of Positive Integer and Negative Integer | Leetcode 2529 | codestorywithMIK
2025-03-10Number of Substrings Containing All Three Characters | Dry Runs | Leetcode 1358 | codestorywithMIK
2025-03-10Are mummy 🥹
2025-03-09Count of Substrings Containing Every Vowel and K Consonants II | Leetcode 3306 | codestorywithMIK
2025-03-08DSA Shorts with MIK - 10 | Avoid TLE in Competitive Programming with Fast I/O
2025-03-07Minimum Recolors to Get K Consecutive Black Blocks | 2 Approaches | Leetcode 2379 | codestorywithMIK
2025-03-06Closest Prime Numbers in Range | 2 Detailed Approaches | Leetcode 2523 | codestorywithMIK
2025-03-05Find Missing and Repeated Values | Mathematical Proof | Leetcode 2965 | codestorywithMIK
2025-03-04Count Total Number of Colored Cells | Maths Proof | 2 Approaches | Leetcode 2579 | codestorywithMIK
2025-03-03Check if Number is a Sum of Powers of Three | Maths Proof | 3 Ways | Leetcode 1780 |codestorywithMIK
2025-03-02Partition Array According to Given Pivot | Multiple Approaches | Leetcode 2161 | codestorywithMIK
2025-03-01Merge Two 2D Arrays by Summing Values | Multiple Approaches | Leetcode 2570 | codestorywithMIK
2025-03-01Nasha hai bhai 🥹
2025-02-27Recursion : The Ultimate Guru 🔥
2025-02-27Aamchi Mumbai, jithe sab kuch possible aahe ❤️
2025-02-26Length of Longest Fibonacci Subsequence | Recursion Memo | Bottom Up |Leetcode 873| codestorywithMIK
2025-02-25Maximum Absolute Sum of Any Subarray | Kadane's Algorithm | Leetcode 1749 | codestorywithMIK
2025-02-24Number of Sub-arrays With Odd Sum | Brute Force | Better | Optimal | Leetcode 1524 |codestorywithMIK
2025-02-23Thoda bed rest lelu ? 🥹
2025-02-22Recovering ❤️‍🩹 🙏