`
cozilla
  • 浏览: 89289 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论
文章列表
Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word: a) Insert a characterb) Delete a characterc) Replace a character     class Solution { public: ...
  class Solution { public: void setZeroes(vector<vector<int> > &matrix) { int h = matrix.size(); int w = 0; if (h > 0) w = matrix[0].size(); bool c1 = false, r1 = false; for (int i = 0; i < h; i++) { if ...
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:   Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer of the previous row.   For example, Consider the following ...
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, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. Note:You are not suppose to us ...
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example,S = "ADOBECODEBANC"T = "ABC" Minimum window is "BANC".
Validate Binary Search Tree Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the ...
  Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.   /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ bool cmp(const ListNode* a, ...
Populating Next Right Pointers in Each Node IIOct 28 '12423 / 1042 Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution still work?
TriangleOct 30 '12 Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ]  
Surrounded RegionsFeb 22 Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.
Longest Consecutive SequenceFeb 14 Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 
Word Ladder Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be changed at a time Each intermediate word must exist in the dictionary For example,
ZigZag ConversionDec 6 '11 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAP ...
  Interleaving String Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = 
Global site tag (gtag.js) - Google Analytics