Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 months ago. Improve this question I need a little help, I made a code to read a sequence of numbers, store them in an array and then print the even
Tag: swap
I want to swap characters of string in java but it returns garbage value can you please tell me what is wrong with my code
I want to swap characters of string but this program returns garbage value. Can you please tell me what is wrong with my code. Answer You have to use constructor of String class. Then it will work fine.
Difficulty trying to sort 10 numbers inputted by a user. Must use arrays and a separate method for sorting
My program isn’t sorting the numbers at all. It displays them in the order they were initially entered. It must sort them from smallest to largest number. The code below should find the largest number in the array and swap it with the last .the code is below: Answer I believe your problem is here: array.length is not less than
What is the time complexity of the following piece of code
here in this java code we are swapping both the arrays, in this case only the memory reference of arrays is changing or there is swapping of elements between A and B? What would be the time complexity O(1) or O(m+n) where m and n are sizes of arrays A and B respectively. This piece of code was found on
swap each element with its neighbour element in an array
I need to write a program. This method will take integer array as input and return array where each value is swapped with its neighbour element. In case the array has odd count, then last element is not swapped. Result: I tried using nested for loops but didnt get it Answer Where is the code you tried so far ?!