Toggle navigation
Marcy Blog
Home
About
Prepare Code Interview
Tags
Marcy Blog
Failed to be a geek
Problem: Remove Duplicates from Sorted Array
Question Given a sorted array, remove the duplicates in-place such that each element appears only once and return the new length. Do not allocate extra space for another array, you must do this b...
Problem: Move Zeroes
Question 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 ca...
Problem: Summary Ranges
Question Given a sorted integer array without duplicates, return the summary of its ranges. Example 1: Input: [0,1,2,4,5,7] Output: ["0->2","4->5","7"] Example 2: Input: [0,2,3,4,6,8,9] O...
Problem: String Compression
Question Given an array of characters, compress it in-place. The length of compression must always be smaller than or equal to the original array. Every element of the array should be a characte...
Problem: Most Common Word
Question Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn’t banned, and th...
Problem: Find All Duplicates in an Array
Question Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twice in this array. Could you do it w...
Problem: First Missing Positive
Question Given an unsorted integer array, find the first missing positive integer. For example, Given [2,1,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses c...
Problem: Missing Numbers
Question Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Example 1 Input: [3,0,1] Output: 2 Example 2 Input: [9,6,4,2,3,5...
Problem: Merge Sorted Array
Question Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (size that is greater or equal to m+n) to h...
Problem: Compare Version Numbers
Question Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assume that the version strings ar...
← Newer Posts
Older Posts →
FEATURED TAGS
Life
Ruby on Rails
Project Management
Agile
Ruby
OOP
Design Patterns
ABOUT ME
To be a top coder, a proud father, and a better man