Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xtenzQ committed Jun 30, 2024
1 parent ef23b76 commit 9497a5d
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

public class TwoPointers {

/**
* Checks if the given string is a palindrome.
*
* @param input the string to check for palindrome properties
* @return {@code true} if the input string is a palindrome, false otherwise
* @implNote This method runs in {@code O(n)} time complexity and {@code O(1)} space complexity, where n is the length of the input string.
*/
public static boolean isPalindrome(String input) {
int start = 0;
int end = input.length() - 1;
Expand All @@ -15,6 +22,14 @@ public static boolean isPalindrome(String input) {
return true;
}

/**
* Checks if there are two distinct elements in the sorted array that sum up to the given target.
*
* @param sortedArray an array of integers that is already sorted in ascending order
* @param target the sum to find in the array
* @return {@code true} if there are two distinct elements in the array whose sum is equal to the target, {@code false} otherwise
* @implNote This method runs in {@code O(n)} time complexity and {@code O(1)} space complexity, where n is the length of the sortedArray.
*/
public static boolean canBeSummed(int[] sortedArray, int target) {
int start = 0;
int end = sortedArray.length - 1;
Expand Down

0 comments on commit 9497a5d

Please sign in to comment.