Largest Number formed from an Array | Largest Number | Comparators Application | Leetcode 179

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



Duration: 20:30
1,352 views
65


iPad PDF Notes - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/iPad%20PDF%20Notes/Largest%20Number%20-%20Leetcode-179.pdf
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 6th Video of our Playlist "C++ STLs : Popular Interview Problems".
In this video we will try to solve a very good problem :
Largest Number - Leetcode 179
Largest Number formed from an Array - GFG

Share your learnings on LinkedIn, Twitter (X), Instagram, Facebook(Meta) with #codestorywithmik & feel free to tag me.

I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.

Problem Name : Largest Number formed from an Array | Largest Number | Comparators Application | Leetcode 179 | GFG POTD
Company Tags : Microsoft, Amazon, MakeMyTrip, Paytm, Zoho, Goldman Sachs
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Arrays/Largest%20Number.cpp
Leetcode Link : https://leetcode.com/problems/largest-number/description/
GfG Link : https://www.geeksforgeeks.org/problems/largest-number-formed-from-an-array1117/1


My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My Recursion Concepts Playlist : https://www.youtube.com/watch?v=pfb1Zduesi8&list=PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Subscribe to my channel : https://www.youtube.com/@codestorywithMIK
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK


Approach Summary :
The purpose of the method is to concatenate the strings in the vector in a way that forms the largest possible number and return the result as a string. To achieve this, a lambda function myComparator is defined as a custom comparator for the sort function. The lambda function compares two strings based on their concatenation in two different orders and returns true if the concatenation of the first string with the second results in a larger number. The vector of strings arr is then sorted using the custom comparator. Finally, the sorted strings are concatenated, and the resulting string is returned as the output of the printLargest method. In the Leetcode version, we have to convert the int to string and then the problem is the same.


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

✨ Timelines✨
00:00 - Introduction
02:22 - Why Greedy Fails ?
04:34 - Brute Force
06:49 - Optimal Breaking it down
11:57 - Writing custom Comparator
15:57 - GFG Coding
18:02 - Leetcode Coding
19:42 - One Corner Case on Leetcode

#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 #2024 #newyear




Other Videos By codestorywithMIK


2024-03-11Shortest Uncommon Substring in an Array | Detailed Intuition | Dry Run | Leetcode 3076 | Contest 388
2024-03-10Custom Sort String | 2 Approaches | Intuition | Meta | Leetcode 791
2024-03-10Maximum Strength of K Disjoint Subarrays | Recursion | Memoization | Leetcode 3077 | Contest 388
2024-03-09Intersection of Two Arrays | 4 Approaches | Leetcode 349
2024-03-08Minimum Common Value | 3 Approaches | Leetcode 2540
2024-03-07Count Elements With Maximum Frequency | One Pass | Two Pass | Leetcode 3005
2024-03-07Happy International Women’s Day, 2024 #womensday #codestorywithmik
2024-03-06Spend your time wisely #codestorywithMIK #motivation #hardwork
2024-03-04Minimum Length of String After Deleting Similar Ends | Simple Two Pointers | Leetcode 1750
2024-03-04Stay tuned - Life Changing Moment
2024-03-04Largest Number formed from an Array | Largest Number | Comparators Application | Leetcode 179
2024-03-02Remove Nth Node From End of List | 1 Pass | 2 Pass | Leetcode 19
2024-03-01Just don't give up. #codestorywithmik
2024-03-01Squares of a Sorted Array | 2 Approaches | Follow Up | Leetcode 977
2024-02-29Maximum Odd Binary Number | 2 Approaches | Leetcode 2864
2024-02-29Comparators in C++ | sort Example | Function Pointer | Functors | Lambda Expressions
2024-02-29Print Longest Common Subsequence | DP On Strings | DP Concepts & Qns-19
2024-02-28Keep moving guys. We are together 💪
2024-02-28Even Odd Tree | DFS | BFS | Leetcode 1609
2024-02-28Permutations II | Two Approaches | Detailed | Recursion Concepts And Questions
2024-02-27Find Bottom Left Tree Value | 3 Approaches | Simple Story | Microsoft | Leetcode 513