Lecture 4 Worksheet.docx

# Lecture 4 Worksheet.docx - Lecture 4 Worksheet Arrays Given...

This preview shows pages 1–2. Sign up to view the full content.

Lecture 4 Worksheet: Arrays Given an array nums , write a function to move all 0 's to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12] , after calling your function, nums should be [1, 3, 12, 0, 0] . Note: 1. You must do this in-place without making a copy of the array. 2. Minimize the total number of operations. public void moveZeroes(int[] nums) { } Given two sorted integer arrays nums1 and nums2 , merge nums2 into nums1 as one sorted array. Ex: Given the arrays [1, 3, 5] and [2, 6, 8] , return the array [1, 2, 3, 5, 6, 8]. nums1 has size n + m , with 0 s at the end of the array

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern