Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Week1/assignments/pembe-miriam/Palindrome.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public class Palindrome {

// Function that checks if sting is a palindrome
static boolean isPalindrome(String string)
{

// Pointers pointing to the beginning
// and the end of the string
int i = 0, j = string.length() - 1;

while (i < j) {

// If there is a mismatch
if (string.charAt(i) != string.charAt(j))
return false;

// Increment first pointer and
// decrement the other
i++;
j--;
}

// Given string is a palindrome
return true;
}

public static void main(String[] args)
{
String string = "mom";

if (isPalindrome(string))
System.out.print("true");
else
System.out.print("false");
}
}
3 changes: 3 additions & 0 deletions Week1/assignments/pembe-miriam/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# About me

My name is Pembe Miriam. I'm a software engineering student at the university of Buea
18 changes: 18 additions & 0 deletions Week1/assignments/pembe-miriam/Staircase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
public class Staircase {

public static void main(String[] args) {
int number = 4;

for (int i = 1; i <= number; i++) {
for (int k = number; k > i; k--) {
System.out.print(" ");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works.
Can you figure out the time complexity of this algorithm and is there any way to make it better?

for (int j = 1; j <= i; j++) {
System.out.print("#");
}
System.out.println();
}

}

}