• Skip to primary navigation
  • Skip to content
  • Skip to footer
zhicheng xie's demo blog
  • Quick-Start Guide

    Your Name

    I am an amazing person.

    • Somewhere

    Generate a String With Characters That Have Odd Counts

    less than 1 minute read

    <-E 1374> Generate a String With Characters That Have Odd Counts

    class Solution {
    public:
        string generateTheString(int n) {
            if(n % 2){
                string a(n, 'a');
                return a;
            }
            else{   
                string a(n-1, 'a');
                return "b"+a;
            }
                
        }
    };
    

    Tags: Algorithms, C++, Leetcode

    Updated: July 26, 2020

    Share on

    Twitter Facebook LinkedIn
    Previous Next

    You may also enjoy

    Decode Ways

    less than 1 minute read

    <-M 91> Decode Ways

    Word Break

    less than 1 minute read

    <-H 139> Word Break

    Distinct Subsequences

    less than 1 minute read

    <-H 115> Distinct Subsequences

    Edit Distance

    less than 1 minute read

    <-H 72> Edit Distance

    • Follow:
    • Feed
    © 2023 zhicheng xie's blog. Powered by Jekyll & Minimal Mistakes.