Posts

Showing posts from 2025

Implementing Linked List

Document Top addFirst() addLast() removeFirst() display() main() Output LINKED LIST IMPLEMENTATION class SinglyLinkedList1 { // Node class private static class Node { String data; Node next; Node(String data) { this.data = data; this.next = null; } } Singly Linked List variables private Node head; // points to the first node private Node tail; // points to the last node private int size; // tracks number of nodes Constructor public SinglyLinkedList1() { head = null; tail = null; size = 0; } To insert an element at the head (beginning) of the list: // Create a new node containing the new element. // Set its next reference to the current head node. // Reassign the head to point to this new node. // Increase the list size by one. // ...

Dice-Random

Image
Document Generate a Random Number

Counter

Image
Document 0 Decrease Increase Reset

Ratio and Proportions

Ratio & Proportion — Aptitude Questions Ratio & Proportion — Aptitude Questions Q1 The monthly emoluments of A and B are in the ratio 3 : 4, while the ratio of their expenditures stands at 4 : 5. If A manages to accumulate ₹600 as savings and B retains ₹800, what is A’s monthly income? Q2 Two quantities are in the ratio 5 : 7. If both are augmented by 20 units, the revised proportion becomes 7 : 9. Determine the original numbers. Solution: Let numbers be 5x and 7x. (5x+20)/(7x+20)=7/9 ⇒ x=10 ⇒ numbers = 50 and 70 . Q3 The ratio of the ages of a father and his son is 7 : 3. After 6 years, the ratio transforms into 9 : 5. Ascertain their present ages. Solution: Let ages be 7x and 3x. (7x+6)/(3x+6)=9/5 ⇒ x=3 ⇒ Father = 21 yrs , Son = 9 yrs . Q4 In a mixture, the pr...

57.Longest Sequence between same character

Image
Print longest sequence between same character Example: I/p abcccccbba O/p 8 (from a to a) I/p aaaaaaaa O/p 6
LeetCode practice builds problem-solving muscles, but interviews are about communicating your thinking in real time and showing that you can adapt when constraints shift. That’s why the same problems that feel trivial alone at your desk can suddenly feel like walls in front of an interviewer. Here are the big gaps you’ve already noticed (and they’re spot on): Thinking out loud: Interviewers want to see your reasoning, not just your final code. Handling changes: They’ll often tweak constraints to test flexibility. Pattern recognition: Spotting whether a problem is, say, sliding window, two-pointer, or DP in disguise. Under-pressure optimization: Interview timing forces you to balance brute force vs. efficient solutions fast. That’s exactly why mock interviews (with peers, mentors, or tools like Leeco AI you mentioned) are so valuable — they recreate the pressure + interaction dynamic that pure grinding doesn’t. suggestions: Don’t stop solving problems, but fr...

56.Remove string 2 froM String 1

Image
Problem of the Day: Given two Strings s1 and s2, remove all the characters from s1 which is present in s2. Input: s1=”expErIence” s2="E" output: s1=”exprIece” Input: s1 = "Programming" s2 = "P" Output: rogramming

55.Print NOT palindrome Strings

Image
Problem of the Day: From the input sentence given, find the strings which are not palindrome and print it. Input: he knows malayalam Output: he knows Input 2: Input: a b c abc cba Output: abc cba

54.Sum of similar frequency element

Image
Problem of the Day: You are given an integer array nums. First, count the frequency of each distinct number in the array. Then, for each frequency f, compute the sum of all numbers in the array that appear exactly f times.Return a mapping (or any suitable output format) where: Key = frequency Value = sum of elements that occur with that frequency Input 1: nums = [1,7,1,1,2,2,2,3,3,5,5] Output: 1 -> 7 2 -> 16 3 -> 9 Input 2: nums = [nums = [1,1,2,2,2,3] Output: 1 -> 3 2 -> 2 3 -> 6

53.Reverse the String According to its Index

Image
Problem of the Day: You are given a string s and an integer k. Your task is to transform the string in the following way: Split the string into groups of size k, starting from index 0. For each group: Rotate the group to the left by 1 character (the first character moves to the end). If the last group has fewer than k characters, still apply the same operation. Finally, return the new transformed string. Input 1: String str1=ZohoCorporations k=3 Output1: hoZoCooprtarnois Input 2: String str1=Hellokid k=2 Output2:eHllkodi

52-Diamond Pattern Printing

Image

51 Adjacent pair not Equal

Image
Problem of the Day: Problem Statement You are given two strings s1 and s2 of equal length. Consider every adjacent pair of characters (substring of length 2) from both strings. Your task is to return all adjacent pairs where the pair in s1 is not equal to the pair in s2. Each result should be represented as "pair1-pair2".. 1.Input s1 = "abcdef" s2 = "abcfed" Output: ["d-f", "d-f", "f-d"]; 2.Input: s1 = "asdfghij" s2 = "adsfgijh" Output: ["sd-ds", "hij-ijh"] .snippet-thumbnail img { max-width: 50px; height: auto; object-fit: cover; }

21 to 30 String Programs

100 Java String Programming Questions 100 Java String Programming Questions 21 to 30 Java Programs 21//Write a program to compare two strings lexicographically. Show Answer class lexicographically { public static void main(String[] args) { String str1="apple"; String str2="Apple"; int comparedValue=(str1.compareTo(str2)); if(comparedValue>0){ System.out.println(str1+ " will comes after "+str2); } else if(comparedValue 22//Write a program to concatenate two strings. Show Answer public class StringConcatenation { public static void main(String[] args) { String str1 = "Hello"; String str2 = "World"; String result1 = str1 + " " + str2; System.out.println("Concatenated string: " + result1); String ...

Problem 50:(Round 2 Java Preparation)

Image
Problem of the Day: You want to sort words lexicographically without using inbuilt functions like Arrays.sort(). Input:{"zebra", "apple", "mango", "ball", "cat", "dog", "elephant", "fish", "ant", "bat"}; Output:ant apple ball bat cat dog elephant fish mango zebra 1. Input: nums1 = [1, 3, 5, 7, 9] nums2 = [2, 3, 5, 6, 8, 9] Output: [1, 2, 3, 5, 6, 7, 8, 9] 2. Input: nums1 = [2, 4, 6, 8] nums2 = [1, 3, 5, 7, 9] Output: [1, 2, 3,4, 5, 6, 7, 8, 9] .snippet-thumbnail img { max-width: 50px; height: auto; object-fit: cover; }

Problem 49:(Round 2 Java Preparation)

Image
Problem of the Day: You want to sort words lexicographically without using inbuilt functions like Arrays.sort(). Input:{"zebra", "apple", "mango", "ball", "cat", "dog", "elephant", "fish", "ant", "bat"}; Output:ant apple ball bat cat dog elephant fish mango zebra .snippet-thumbnail img { max-width: 50px; height: auto; object-fit: cover; }

Merge Two Sorted Arrays Without Duplicates

Image
Problem of the Day: You are given two sorted arrays of integers, nums1 and nums2. Your task is to merge them into a single sorted array that contains only unique elements. Do not use any built-in sorting function. Use only one loop to traverse and merge. 1. Input: nums1 = [1, 3, 5, 7, 9] nums2 = [2, 3, 5, 6, 8, 9] Output: [1, 2, 3, 5, 6, 7, 8, 9] 2. Input: nums1 = [2, 4, 6, 8] nums2 = [1, 3, 5, 7, 9] Output: [1, 2, 3,4, 5, 6, 7, 8, 9] .snippet-thumbnail img { max-width: 50px; height: auto; object-fit: cover; }

String (11 to 20) Programs

100 Java String Programming Questions 100 Java String Programming Questions Series(11 to 20) 11. Write a program to convert string into LowerCase. Show Answer class StringToLowerCase { public static void main(String[] args) { String str = "ApplE"; char c;; System.out.println("Input given is - " + str); for (int i = 0; i = 65 && str.charAt(i) 12.Write a program to convert uppercase letters to lowercase and vice versa.. Show Answer public class ToggleCase { public static void main(String[] args) { String text = "HeLLo WoRLd JaVa123"; System.out.println("Input text is : " + text); System.out.print("Toggled: "); for (int i = 0; i = 'A' && ch = 'a' && ch 13.Write a program to remove vowels from a string. Show Answer public class RemoveVowels { public static void main...
Image
Problem of the Day: Remove Duplicate Characters and Digits with Different Rules You are given a string s consisting of lowercase English letters and digits (0–9). You must transform the string in two steps: Characters (a–z): Traverse from left to right. Keep only the first occurrence of each character. Remove all later duplicates. Digits (0–9): Traverse from right to left. Keep only the first digit you encounter (the rightmost occurrence in the original string). Remove earlier duplicates. Return the final transformed string. 1.Input: programming123321 After Step1: progamin123321 Final: progamin321 (keeps the rightmost 1,2,3 — final digits appear as the left-to-right order of their last occurrences) 2. Input: abc11223344 After Step1: abc11223344 Final: abc1234 3. Input: a1b2c1d2e3 After Step1: a1b2c1d2e3 Final: abc1d2e3

String -(Programs 1-10)

100 Java String Programming Questions 100 Java String Programming Questions 1. Write a program to find the length of a string. Show Answer class StringLength { public static void main(String[] args) { String str = "Hello World"; System.out.println("Length of string: " + str.length()); } } 2. Write a program to print each character of a string. Show Answer public class PrintCharacters { public static void main(String[] args) { String str = "Hello Java"; for (int i = 0; i 3. Write a program to reverse a string. Show Answer public class ReverseString { public static void main(String[] args) { String str = "Hello"; String reversed = new StringBuilder(str).reverse().toString(); System.out.println("Reversed: " + reversed); } } 4. Write a program to check a string is palindrom...

Strings

100 Java String Programming Questions 100 Java String Programming Questions A clean list of 100 string-focused programming questions in Java — arranged Basic → Intermediate → Advanced. Copy this HTML into your Blogger post's HTML editor and tweak the CSS variables at the top to change colors and fonts. A. Basic String Programs (1–40) Write a program to find the length of a string. Write a program to print each character of a string. Write a program to reverse a string. Write a program to check if a string is a palindrome. Write a program to count vowels in a string. Write a program to count consonants in a string. Write a program to count digits in a string. Write a program to count spaces in a string. Write a program to count special characters in a string. Write a program to conver...

Arrays

100 Java Array Programming Questions 100 Java Array Programming Questions A curated list of 100 array-focused programming questions in Java — arranged Basic → Medium → Difficult. Paste this into your Blogger post and edit the colors/font variables in the <style> block. Java • Arrays • Practice A. Basic Array Programs (1–40) Write a program to read and print elements of an array. Write a program to find the length of an array. Write a program to print array elements in reverse order. Write a program to find the sum of array elements. Write a program to find the average of array elements. Write a program to find the maximum element in an array. Write a program to find the minimum element in an array. Write a program to search for an element in an array (linear search). Write a program to count even numbers in an a...

Lets check 41 to 46

Image
 

Let's Check 36 to 40

Image
 

Lets Check- 31-35 Java Questions

Image
 

Lets Check- 26-30 Java Questions

Image