Pradumya Gupta’s Post

šŸš€ Day 77 of #100DaysOfCode — Find the Second Largest Digit Hey everyone! šŸ‘‹ Today's challenge isĀ "Second Largest Digit in a String" — a great problem for practicingĀ digit extraction,Ā comparison logic, andĀ edge-case handling. We’ll search through a mixed string of letters and numbers to find theĀ second largest digit, or returnĀ -1Ā if it doesn’t exist. šŸ‘ØšŸ’»Ā What l practiced today: āœ…Ā String Traversal: Looping through each character and identifying digits. āœ…Ā Digit Comparison: Keeping track of the largest and second-largest digits efficiently. āœ…Ā Edge Cases: Handling cases with no digits, only one digit, or duplicate digits. šŸ“ŒĀ Today’s Task: āœ” Given an alphanumeric stringĀ s. āœ” Return theĀ second largest numerical digitĀ that appears inĀ s. āœ” ReturnĀ -1Ā if it doesn’t exist. Example: Input:Ā s = "dfa12321afd" Digits:Ā [1, 2, 3] Second largest:Ā 2 → Output:Ā 2 🧠 Key Insight: You can solve this by scanning the string once, tracking theĀ largestĀ andĀ second largestĀ digits. Remember toĀ skip duplicatesĀ and handle cases where all digits are the same. #100DaysOfCode #Day77 #Python #LeetCode #DSA #StringManipulation #DigitExtraction #EdgeCases #AlgorithmPractice #LogicBuilding

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories