Back to Browse

LeetCode 1295: Find Numbers with Even Number of Digits (Java) | 2 Solutions (Loop & Math function)

6 views
Premiered Nov 23, 2025
4:29

🚀 Master LeetCode 1295: Find Numbers with Even Number of Digits in Java! In this video, we tackle the popular array problem LeetCode 1295. I will walk you through two distinct ways to solve this problem, taking you from a beginner-friendly iterative approach to an optimized mathematical one line solution. 📝 What you will learn in this tutorial: The Iterative Approach: How to use a while loop and division to manually count the digits of each number in an array. The Mathematical Trick (0ms Runtime): How to use (int)(Math.log10(n)) + 1 to instantly find the digit count without loops—a favorite trick for coding interviews! Java Implementation: Clean and readable coding standards. Whether you are preparing for coding interviews or just practicing Data Structures and Algorithms (DSA), this video will help you understand array manipulation and digit logic. 💡 Problem Statement: Given an array nums of integers, return how many of them contain an even number of digits. 📌 Timestamps: 00:00 - Introduction & Problem Analysis 00:52 - Logic: How to count digits? 01:35 - Method 1: The While Loop Approach 03:20 - Method 2: The Math.log10 One-Liner (Optimization) 04:15 - Final Code Run & Submission 💻 Code Snippet (Math Approach): // Fast way to find digit count return (int)(Math.log10(num)) + 1; 🔔 Subscribe for more LeetCode solutions and coding tutorials! If you found this video helpful, please hit the Like button and drop a comment if you have a different way to solve it! #LeetCode #Java #Programming #CodingInterview #DataStructures #Algorithms #LeetCode1295 #JavaProgramming #SoftwareEngineering

Download

0 formats

No download links available.

LeetCode 1295: Find Numbers with Even Number of Digits (Java) | 2 Solutions (Loop & Math function) | NatokHD