Lesson 15 of 34

Array Algorithms: Reverse, Search, Sort

10 min 30 XP

java.util.Arrays class-এ কাজের helpers আছে: Arrays.toString() array সুন্দরভাবে print করে, Arrays.sort() তা sort করে।

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Interview-এ প্রায়ই library-র সাহায্য ছাড়া করতে বলা হয়। Array উল্টাতে দুই প্রান্ত থেকে swap করতে করতে মাঝখানে মিলুন (two-pointer technique)।

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

দুটি value swap করতে একটিকে ধরে রাখার জন্য temp variable লাগে।

Challenge

+30 XP

n এবং n-টি সংখ্যা পড়ে উল্টো ক্রমে এক লাইনে, space দিয়ে আলাদা করে print করুন। Input: 5 1 2 3 4 5 Output: 5 4 3 2 1

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.