Skip to main content

Command Palette

Search for a command to run...

Faulty Keyboard

Published
1 min read
Faulty Keyboard
G

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.

I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.

Your laptop keyboard is faulty, and whenever you type a character 'i' on it, it reverses the string that you have written. Typing other characters works as expected.

You are given a 0-indexed string s, and you type each character of s using your faulty keyboard.

Return the final string that will be present on your laptop screen.

LeetCode Problem - 2810

class Solution {
    // Method to generate the final string after processing the input string
    public String finalString(String s) {
        // StringBuilder to build the final string efficiently
        StringBuilder sb = new StringBuilder();

        // Iterating through each character of the input string
        for(int i = 0; i < s.length(); i++) {
            // Getting the current character
            char currentChar = s.charAt(i);

            // Reversing the StringBuilder if the current character is 'i'
            if(currentChar == 'i') {
                sb.reverse();
            } else {
                // Appending the current character to the StringBuilder if it's not 'i'
                sb.append(currentChar);
            }
        }
        // Converting the StringBuilder to a string and returning it
        return sb.toString();
    }
}

More from this blog

S

Software and Performance Testing Insights

462 posts

Results-Driven Agile QA Specialist | Expert in Mobile & Web Testing | Proficient in Test Planning, Execution, and Root Cause Analysis.