From 0c90913793522ee9a2417b9efe82d99e18dd34bb Mon Sep 17 00:00:00 2001 From: Deyan Peev Date: Sun, 6 Nov 2022 09:04:37 +0200 Subject: [PATCH] Homework --- Seminar 3/Homework/Problem1.md | 47 ++++++++++++++++++++++++++++++++++ Seminar 3/Homework/Problem2.md | 23 +++++++++++++++++ Seminar 3/Homework/Problem3.md | 25 ++++++++++++++++++ Seminar 3/Homework/Problem4.md | 23 +++++++++++++++++ Seminar 3/Homework/Problem5.md | 23 +++++++++++++++++ Seminar 3/Homework/Problem6.md | 23 +++++++++++++++++ 6 files changed, 164 insertions(+) create mode 100644 Seminar 3/Homework/Problem1.md create mode 100644 Seminar 3/Homework/Problem2.md create mode 100644 Seminar 3/Homework/Problem3.md create mode 100644 Seminar 3/Homework/Problem4.md create mode 100644 Seminar 3/Homework/Problem5.md create mode 100644 Seminar 3/Homework/Problem6.md diff --git a/Seminar 3/Homework/Problem1.md b/Seminar 3/Homework/Problem1.md new file mode 100644 index 0000000..a09de6a --- /dev/null +++ b/Seminar 3/Homework/Problem1.md @@ -0,0 +1,47 @@ +# Find min/max number in array + +## Find max +Given an array of integers find the biggest integer. + +--- +Sample input: +``` java +[1,2,1,51,2] +``` +Sample output: +``` java +51 +``` +--- +Sample input: +``` java +[1000,2,200, -5124] +``` +Sample output: +``` java +1000 +``` +--- + +## Find min +Given an array of integers find the smallest integer. + +--- +Sample input: +``` java +[1,2,1,51,2] +``` +Sample output: +``` java +1 +``` +--- +Sample input: +``` java +[1000,2,200, -5124] +``` +Sample output: +``` java +-5124 +``` + diff --git a/Seminar 3/Homework/Problem2.md b/Seminar 3/Homework/Problem2.md new file mode 100644 index 0000000..98c9c9b --- /dev/null +++ b/Seminar 3/Homework/Problem2.md @@ -0,0 +1,23 @@ +# Longest string in array +Given array of strings, find the string with the most characters. + +There can be more than one string with the most characters. In such case, print all strings with the max length. + +--- +Sample input: +``` java +["gosho", "PeSho", "StaMAT", "Roki 5", "Baba Dobrinka", "Devata ot Gladalupe"] +``` +Sample output: +``` +Devata ot Gladalupe +``` +--- +Sample input: +``` java +["gosho", "PeSho", "StaMAT", "Roki 5"] +``` +Sample output: +``` +StaMAT, Roki 5 +``` \ No newline at end of file diff --git a/Seminar 3/Homework/Problem3.md b/Seminar 3/Homework/Problem3.md new file mode 100644 index 0000000..2842835 --- /dev/null +++ b/Seminar 3/Homework/Problem3.md @@ -0,0 +1,25 @@ +# Reverse words in a string +Given a string, return a new string that has all the words in reversed order.t all strings with the max length. + +--- +Sample input: +``` java +"This is a string sentense" +``` +Sample output: +``` +sihT si a gnirts esnetnes +``` +--- +Sample input: +``` java +"My second sentence to reverse" +``` +Sample output: +``` +yM dnoces ecnetnes ot esrever +``` + +
Hint +Use the string method .split() to make an array of strings and then assemble them back. +
\ No newline at end of file diff --git a/Seminar 3/Homework/Problem4.md b/Seminar 3/Homework/Problem4.md new file mode 100644 index 0000000..f3866c2 --- /dev/null +++ b/Seminar 3/Homework/Problem4.md @@ -0,0 +1,23 @@ +# Find longest sequesnce of repeating numbers +Given an array of integers, return the integers that repeats sequentially the most times. + +In case, there is more than one numbers with the same number of reapeating times, return the first. + +--- +Sample input: +``` java +[6, 5, 2, 2, 5, 6, 7, 5, 5] +``` +Sample output: +``` +2 +``` +--- +Sample input: +``` java +[-12, -4, 5, 5, 5, 6, 7, 12, 12, 12, 12, 5, 5, 5] +``` +Sample output: +``` +12 +``` \ No newline at end of file diff --git a/Seminar 3/Homework/Problem5.md b/Seminar 3/Homework/Problem5.md new file mode 100644 index 0000000..1f2483c --- /dev/null +++ b/Seminar 3/Homework/Problem5.md @@ -0,0 +1,23 @@ +# Find longest sequesnce of progressing sequential numbers +Given an array of integers, return the longest progresing sequence. + +In case there are more than one progressing sequence repeating same max number of times, return the first. + +--- +Sample input: +``` java +[500, 5, 6, 7, 1, 2] +``` +Sample output: +``` +5,6,7 +``` +--- +Sample input: +``` java +[-4, -5, 0, 2, 100, 0, 1, 2, 3] +``` +Sample output: +``` +-5, 0, 2, 100 +``` \ No newline at end of file diff --git a/Seminar 3/Homework/Problem6.md b/Seminar 3/Homework/Problem6.md new file mode 100644 index 0000000..015973c --- /dev/null +++ b/Seminar 3/Homework/Problem6.md @@ -0,0 +1,23 @@ +# Find longest sequesnce of progressing non-sequential numbers +Given an array of integers, return the longest non-sequential progressing sequence. + +In case there are more than one progressing sequence repeating same max number of times, return the first. + +--- +Sample input: +``` java +[1, 0, 500, 5, 6, 7, 1, 2] +``` +Sample output: +``` +1, 5,6,7 +``` +--- +Sample input: +``` java +[-4, -5, 0, 2, 100, -2, 0, 1, 2, 3] +``` +Sample output: +``` +-4, 0, 0, 1, 2, 3 +``` \ No newline at end of file