Lesson 15 of 34
Array Algorithms: Reverse, Search, SortArray Algorithms: Reverse, Search, Sort
10 min 30 XP
java.util.Arrays class-ல் பயனுள்ள methods உள்ளன: Arrays.toString() array-ஐ அழகாக print செய்யும், Arrays.sort() வரிசைப்படுத்தும்.
The java.util.Arrays class has handy helpers: Arrays.toString() prints an array neatly and Arrays.sort() sorts it.
Example: edit me and press Run
Press Run to see the result here.Interview-ல் library இல்லாமல் எழுதச் சொல்வார்கள். Array-ஐ reverse செய்ய: இரண்டு முனைகளிலிருந்தும் swap செய்து நடுவில் சந்திக்கவும் (two pointers).
Interviews often ask you to do it without library help. To reverse an array, swap from both ends and meet in the middle (the two-pointer technique).
Example: edit me and press Run
Press Run to see the result here.இரண்டு மதிப்புகளை swap செய்ய ஒரு temp variable தேவை.
Swapping two values needs a temp variable to hold one of them.