摘要:
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string "23"Output: ["ad", "ae", "af", "bd", "be", &q 阅读全文
摘要:
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5. Note: Given n will always be valid. Try to do this in one 阅读全文
摘要:
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.class Solution {public: struct Node{ ListNode *p; Node(ListNode* pointer):p(pointer){ } //make heap的时候,k和2k 2k+1的孩子比较,这样就会采用 rs.p->val bool operator val > rs.p-... 阅读全文
摘要:
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]&qu 阅读全文
摘要:
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 algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed.class Solution 阅读全文
摘要:
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.class Solution {public: //这个版本的快排要记住 //这个版本的Partition是 Hoare的版本 int removeElement(int A[], int n, in... 阅读全文
摘要:
Divide two integers without using multiplication, division and mod operator.class Solution {public: int divide(int dividend, int divisor) { // Start typing your C/C++ solution below // DO NOT write int main() function assert(divisor); int ans = 0, step = 1, negative = ... 阅读全文
摘要:
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.class Solution {public: string add(string num1, string num2){ int i = 0, j = 0, c = 0,m = 0; string ans; while(i < num1.s... 阅读全文