7 Days of Java Coding Practice – My Structured Preparation Plan

Published: (February 19, 2026 at 01:01 AM EST)
3 min read
Source: Dev.to

Source: Dev.to

Day 1 – Basic Number Problems

Reverse a Number

  • Extract digits using % 10 and rebuild the number using rev * 10.
  • Time Complexity: O(d) (where d is the number of digits)
  • Space Complexity: O(1)

Palindrome Number

  • Reverse the number and compare it with the original.

Sum of Digits

  • Extract each digit and add them until the number becomes zero.

These problems helped me understand digit extraction and number manipulation clearly.


Day 2 – Recursion and Mathematical Concepts

Count Digits

  • Keep dividing the number by 10 until it becomes zero.

Fibonacci Series

  • Iterative approach – efficient, O(n)
  • Recursive approach – simple logic but exponential complexity

This helped me understand the difference between optimized and non‑optimized solutions.

Factorial

  • Practiced both iterative and recursive approaches.

Armstrong Number

  • Checked whether the sum of cubes of digits equals the original number (for 3‑digit numbers).

Sum of Digits Until Single Digit

  • Repeatedly calculated digit sum until a single digit remains (digital‑root concept).

Day 3 – Prime and Special Numbers

Check Prime Number

  • Initially used an O(n) approach. Later optimized to check only up to √n.
  • Applied nested loops for prime checking.

Strong Number

  • Example: 145 = 1! + 4! + 5!

These problems improved my mathematical thinking and loop control.


Day 4 – Array Basics

Bubble Sort

  • Understood how comparison‑based sorting works.
  • Time Complexity: O(n²)

Maximum Element in Array

  • Traverse and update the max value.

Second Largest Element

  • Maintain two variables to track the first and second largest values.

Reverse an Array

  • Printed in reverse order and also practiced the swapping method.

Adding Element in Array

  • Inserted an element at the end and at a specific position.

These strengthened my array traversal and indexing logic.


Day 5 – Array Rotations and Duplicates

Remove Duplicates (Sorted Array)

  • Used the two‑pointer technique.

Left Rotate by 1

  • Shifted elements one position to the left.

Right Rotate by 1

  • Shifted elements one position to the right.

Left Rotate by K

  • Understood how shifting works internally and how to improve performance.

Day 6 – String Basics

Reverse a String

  • Initially used string concatenation (O(n²)).
  • Later switched to StringBuilder for O(n) efficiency.

Palindrome String

  • Reverse and compare using equals().

Count Vowels

  • Traversed each character and checked vowel conditions.

Character Frequency

  • Used a frequency array of size 256.

This day helped me understand string immutability and character handling.


Day 7 – Advanced String Problems

Anagram

  • Incremented frequency for the first string and decremented for the second.

First Non‑Repeating Character

  • Used frequency count and scanned the string again.

Check Unique Characters

  • Ensured no character appears more than once.

Reverse Each Word in a Sentence

  • Split the sentence and reversed each word individually.

These problems boosted my confidence in solving string‑based interview questions.


What I Learned

  • Improved logical thinking.
  • Better understanding of time and space complexity.
  • Learned the difference between brute‑force and optimized approaches.
  • Strengthened recursion basics.
  • Practiced two‑pointer technique.
  • Gained confidence in writing clean Java code.

Instead of solving hundreds of random problems, I focused on mastering around 30 fundamental problems deeply. That gave me much more clarity and confidence.

0 views
Back to Blog

Related posts

Read more »

Interface in Java

Introduction An interface in Java is used to achieve abstraction and multiple inheritance. It defines what a class should do, but not how it should do it. What...