Largest Number formed from an Array | Largest Number | Comparators Application | Leetcode 179
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