Toggle navigation
Marcy Blog
Home
About
Prepare Code Interview
Tags
Marcy Blog
Failed to be a geek
Problem: Reverse Linked List
Question Reverse a singly linked list. Solution TODO Code class Solution { public ListNode reverseList(ListNode head) { if(head == null) return null; if(head.next == null) re...
Problem: Queue Reconstruction by Height
Question Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in f...
Problem: Wiggle Sort
Question Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... Example: Input: nums = [3,5,2,1,6,4] Output: One possible answer is [3,...
Problem: Merge Two Sorted Lists
Question Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example: Input: 1->2->4, 1->3->...
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 ...
Problem: Merge Intervals
Question Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. Solution TODO Code class Solution { pu...
Problem: Reorder Log Files
Question You have an array of logs. Each log is a space delimited string of words. For each log, the first word in each log is an alphanumeric identifier. Then, either: Each word after the ...
Problem: Meeting Rooms
Question Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings. For example, Given [[0, 30...
Problem: Number of Nodes in a Complete Tree
Question Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is complete...
Problem: Find First and Last Position of Element in Sorted Array
Question Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm’s runtime complexity must be in the order of O(log n)....
← 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