-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlgorithmicQuestions.cs
More file actions
54 lines (47 loc) · 1.2 KB
/
AlgorithmicQuestions.cs
File metadata and controls
54 lines (47 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Practice
{
public static class AlgorithmicQuestions
{
public static string ReverseString(string input)
{
char[] chars = input.ToCharArray();
int left = 0, right = chars.Length - 1;
while (left < right)
{
char temp = chars[left];
chars[left] = chars[right];
chars[right] = temp;
left++;
right--;
}
return new string(chars);
}
public static bool IsPalindrome(string s)
{
int left = 0, right = s.Length - 1;
while (left < right)
{
if (s[left] != s[right])
return false;
left++;
right--;
}
return true;
}
public static int FindMax(int[] arr)
{
int max = arr[0];
foreach (int num in arr)
{
if (num > max)
max = num;
}
return max;
}
}
}