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

Commit a4f0239

Browse files
feat: palindrome
1 parent 0e0ef1b commit a4f0239

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

‎README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Algorithm and Data Structure Exercises
2+
3+
Welcome to my repository of algorithm and data structure exercises! This repository contains the source code and tests for various problems I solve in my YouTube videos. Follow along with the videos and find the corresponding code here.
4+
5+
### Introduction
6+
7+
This repository is dedicated to solving a wide range of algorithm and data structure problems. The exercises range from basic to advanced levels and are designed to help improve your problem-solving skills.
8+
9+
Link to my YouTube Channel: [YouTube Channel](https://www.youtube.com/@sheratrium/featured)

‎src/2_palindrome/index.ts‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@
77
// palindrome("appa") === true
88
// palindrome("qwerty") === false
99

10-
export const palindrome = (str: string) => {
11-
return '';
12-
}
10+
// #1 Solution
11+
// export const palindrome = (str: string): boolean => {
12+
// const reversedString = str.split('').reverse().join('');
13+
14+
// return str === reversedString;
15+
// }
16+
17+
// #2 Solution
18+
// export const palindrome = (str: string): boolean => {
19+
// const reversedString = str.split('').reduce((rev, char) => char + rev, '');
20+
21+
// return str === reversedString;
22+
// };
23+
24+
// #3 Solution
25+
export const palindrome = (str: string): boolean => {
26+
let reversedString = '';
27+
28+
for (let char of str) {
29+
reversedString = char + reversedString;
30+
}
31+
32+
return str === reversedString;
33+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /