Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

your ticket to the dev world

License

NotificationsYou must be signed in to change notification settings

jfullstackdev/java-coding-problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 

Repository files navigation

updated July 28, 2024

Hits

These are the most common coding problems being asked duringtechnical interviews, as I experienced it myself.

Running The Code

It's the convenience of Codespaces online! Simply create a Codespace, you don't need to install anything, just run using Bash.

Steps to Run the Code

  1. Fork the Repository:

    • Navigate to the repository you want to fork.
    • Click the "Fork" button at the top right corner of the page.
  2. Create a Codespace:

    • Go to your forked repository.
    • Click the "Code" button.
    • Select "Open with Codespaces" from the dropdown menu.
    • If you have Codespaces enabled, you will see an interface like this:Codespaces
  3. Navigate to the Source Directory:

    • Open the terminal in Codespaces.
    • Change the directory tosrc:
      cd src
  4. Run the Java File:

    • Starting with Java 11, you can run Java files without compiling them first. Use the following command:

      java [NameOfTheFile].java

this is the sample interface of the online Codespaces

Codespaces Interface

enjoy!

Source Code

  1. Binary Search

    • Problem: Implement a binary search algorithm to find the position of atarget value within a sorted array.
    • Link:View Code
    • Discussion: Binary search is an efficient algorithm for finding an itemfrom a sorted list of items. It works by repeatedly dividing in half theportion of the list that could contain the item, until you've narrowed downthe possible locations to just one.
  2. Checking Palindrome

    • Problem: Check if a given string is a palindrome.
    • Link:View Code
    • Discussion: A palindrome is a word, phrase, number, or other sequenceof characters that reads the same forward and backward (ignoring spaces,punctuation, and capitalization). The algorithm typically involvescomparing characters from the beginning and end of the string movingtowards the center.
  3. Inheritance

    • Problem: Demonstrate the concept of inheritance in Java.
    • Link:View Code
    • Discussion: Inheritance is a fundamental concept in object-orientedprogramming where a new class is created from an existing class. The newclass (subclass) inherits attributes and methods from the existing class(superclass), allowing for code reuse and the creation of a hierarchicalrelationship between classes.
  4. Integer Array Sum

    • Problem: Calculate the sum of all integers in an array.
    • Link:View Code
    • Discussion: This problem involves iterating through an array ofintegers and accumulating the sum of its elements. It is a straightforwardproblem that demonstrates basic array manipulation and iteration.
  5. Merge Sort

    • Problem: Implement the merge sort algorithm.
    • Link:View Code
    • Discussion: Merge sort is a divide-and-conquer algorithm that dividesthe input array into two halves, recursively sorts them, and then mergesthe sorted halves. It is known for its efficiency and stable sortingproperties.
  6. Prime Number Checker

    • Problem: Check if a given number is a prime number.
    • Link:View Code
    • Discussion: A prime number is a natural number greater than 1 that hasno positive divisors other than 1 and itself. The algorithm typicallyinvolves checking divisibility from 2 up to the square root of the number.
  7. Fibonacci Series

    • Problem: Print the Fibonacci series up to a given number.
    • Link:View Code
    • Discussion: The Fibonacci series is a sequence where each number is thesum of the two preceding ones, usually starting with 0 and 1. This problemcan be solved using iterative or recursive approaches.
  8. Remove A Character

    • Problem: Remove all occurrences of a given character from a string.
    • Link:View Code
    • Discussion: This problem involves iterating through the string andbuilding a new string that excludes the specified character. Itdemonstrates string manipulation techniques.
  9. Remove Whitespaces

    • Problem: Remove all whitespaces from a string.
    • Link:View Code
    • Discussion: This problem involves iterating through the string andbuilding a new string that excludes all whitespace characters. It is acommon string manipulation task.
  10. Reverse A Linked List

    • Problem: Reverse a singly linked list.
    • Link:View Code
    • Discussion: Reversing a linked list involves changing the direction ofthe pointers in the list. This problem is a classic example of pointermanipulation in data structures.
  11. Reverse A String

    • Problem: Reverse a given string.
    • Link:View Code
    • Discussion: Reversing a string involves swapping characters from thebeginning and end of the string moving towards the center. It is a basicstring manipulation problem.
  12. Shuffle Array

    • Problem: Shuffle the elements of an array randomly.
    • Link:View Code
    • Discussion: Shuffling an array involves randomly permuting itselements. This can be achieved using algorithms like the Fisher-Yatesshuffle.
  13. Sort Array

    • Problem: Sort an array of integers.
    • Link:View Code
    • Discussion: Sorting an array involves arranging its elements in aspecific order (ascending or descending). Various algorithms can be used,such as quicksort, mergesort, or bubble sort.
  14. Check Vowels

    • Problem: Check if a string contains any vowels.
    • Link:View Code
    • Discussion: This problem involves iterating through the string andchecking for the presence of vowel characters (a, e, i, o, u). Itdemonstrates basic string traversal and condition checking.

License

This is based on :

https://www.journaldev.com/370/java-programming-interview-questions

I don't know about the specific license the author usedbut I'm still including his link for his copyright.

When you copy my work, include the author's linkand my MIT license for my modifications.

More Java Projects

for more Java discussion and other details,check the Main Page ->Java

More Of My Content


[8]ページ先頭

©2009-2025 Movatter.jp