Given a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list as 2->1->4->3.Your al... Read More
posted @ 2014-07-14 23:48 Xylophone Views(102) Comments(0) Diggs(0)
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, ... Read More
posted @ 2014-07-14 23:08 Xylophone Views(128) Comments(0) Diggs(0)
Given two binary strings, return their sum (also a binary string).For example, a = "11" b = "1" Return "100".class Solution {public: string addBina... Read More
posted @ 2014-07-14 21:57 Xylophone Views(137) Comments(0) Diggs(0)
Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For ... Read More
posted @ 2014-07-14 15:49 Xylophone Views(194) Comments(0) Diggs(0)
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1... Read More
posted @ 2014-06-29 23:40 Xylophone Views(261) Comments(0) Diggs(0)
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you cli... Read More
posted @ 2014-06-28 10:06 Xylophone Views(185) Comments(0) Diggs(0)
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... Read More
posted @ 2014-06-27 22:29 Xylophone Views(142) Comments(0) Diggs(0)
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ... Read More
posted @ 2014-06-24 17:22 Xylophone Views(174) Comments(0) Diggs(0)
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... Read More
posted @ 2014-06-23 16:22 Xylophone Views(130) Comments(0) Diggs(0)
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... Read More
posted @ 2014-06-23 15:52 Xylophone Views(119) Comments(0) Diggs(0)