Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

return string consistent of n lowercase letters such is all letters occurs an odd number

 public String generateTheString(int n) {
        int count = (n % 2 == 0) ? n - 1 : n;
        StringBuilder result  = new StringBuilder();

        result.append("x".repeat(Math.max(0, count)));

        if( n % 2 == 0){
            result.append('y');
        }
        return result.toString();
    }
Comment

PREVIOUS NEXT
Code Example
Java :: calculate tip and sales tax function 
Java :: sha1 
Java :: print method in java 
Java :: Iterating The Queue Elements 
Java :: spring boot dto example java 
Java :: java longest paldrome 
Java :: how to implement seekbar for music in java 
Java :: adding prefix zeros 
Java :: java function that returns the index of the largest value in an array 
Java :: where do you use overriding in framework 
Java :: find maximum number of rides in amusement park python 
Java :: Kotlin const to Java 
Java :: java 2d array previous object 
Java :: javax.servlet.ServletException: javax.servlet.jsp.JspException: Missing message for key 
Java :: java how to slit a dtring and trim at the same time 
Java :: java program on stack for beginners 
Java :: aggregationoperation multi match 
Java :: android on change class event 
Java :: jdbc insert example from input values 
Java :: Designing a HashMap Key 
Java :: java run multiple cmd commands 
Java :: Java Creating WeakHashMap from Other Maps 
Java :: Meditation for stress and depression 
Java :: add element to queue java 
Java :: current currency rates api 
Java :: subtract two variables in java 
Java :: get steps counts using pedometer sensor in android 
Java :: labelled for loop in java 
Java :: younger brother of java 
Java :: java tostring methode überschreiben 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =