摘要:
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements ofnums except n 阅读全文
摘要:
Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: 347. Top K Fr 阅读全文
摘要:
Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c" click to show co 阅读全文
摘要:
Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: Note: All inputs will be i 阅读全文
摘要:
Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Update (2015-02-12):For C pr 阅读全文
摘要:
Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", t = 阅读全文
摘要:
Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators a 阅读全文
摘要:
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below 阅读全文
摘要:
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the 阅读全文
摘要:
Write a function to find the longest common prefix string amongst an array of strings 题目:找vector中最长公共前缀, 思路:模拟比较的过程,我们可以看到这些. 按照数组中的第一个字符串开始进行比较, 对第一个 阅读全文
摘要:
Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element i 阅读全文
摘要:
Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each elemen 阅读全文
摘要:
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then l 阅读全文
摘要:
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy 阅读全文
摘要:
Sort a linked list in O(n log n) time using constant space complexity. 题目:有时间和空间复杂度限制 单链表适合利用归并排序, 双向链表适合利用快速排序, 复用mergeTwoList()代码 1,利用fast/slow方法找到链 阅读全文
摘要:
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 合并k个链表形成一个已排序链表 思路: 如何合并两个有序链表?经典merge算法: 对vector中的 阅读全文
摘要:
Sort a linked list using insertion sort. 思路: 怎么判断链表开始? 怎么判断链表结束? 定义dummy假的头节点,这样的话直接就有了链表头dummy.next 怎么将curr指向的节点插入到in指向的位置? 四步就可以完成:ListNode *tmp = c 阅读全文
摘要:
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文
摘要:
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 阅读全文