Skip to content

Commit 0409840

Browse files
committed
Add solution #1374
1 parent e690a31 commit 0409840

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
1356|[Sort Integers by The Number of 1 Bits](./1356-sort-integers-by-the-number-of-1-bits.js)|Easy|
145145
1360|[Number of Days Between Two Dates](./1360-number-of-days-between-two-dates.js)|Easy|
146146
1365|[How Many Numbers Are Smaller Than the Current Number](./1365-how-many-numbers-are-smaller-than-the-current-number.js)|Easy|
147+
1374|[Generate a String With Characters That Have Odd Counts](./1374-generate-a-string-with-characters-that-have-odd-counts.js)|Easy|
147148
1380|[Lucky Numbers in a Matrix](./1380-lucky-numbers-in-a-matrix.js)|Easy|
148149
1472|[Design Browser History](./1472-design-browser-history.js)|Medium|
149150
1598|[Crawler Log Folder](./1598-crawler-log-folder.js)|Easy|
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* 1374. Generate a String With Characters That Have Odd Counts
3+
* https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts/
4+
* Difficulty: Easy
5+
*
6+
* Given an integer n, return a string with n characters such that each character in such
7+
* string occurs an odd number of times.
8+
*
9+
* The returned string must contain only lowercase English letters. If there are multiples
10+
* valid strings, return any of them.
11+
*/
12+
13+
/**
14+
* @param {number} n
15+
* @return {string}
16+
*/
17+
var generateTheString = function(n) {
18+
return 'a'.repeat(n % 2 ? n : n - 1) + (n % 2 ? '' : 'z');
19+
};

0 commit comments

Comments
 (0)