Lesson 15 of 34

Array Algorithms: Reverse, Search, Sort

10 min 30 XP

java.util.Arrays class-ல் பயனுள்ள methods உள்ளன: Arrays.toString() array-ஐ அழகாக print செய்யும், Arrays.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-ஐ reverse செய்ய: இரண்டு முனைகளிலிருந்தும் swap செய்து நடுவில் சந்திக்கவும் (two pointers).

Example: edit me and press Run

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

இரண்டு மதிப்புகளை 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.