• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

xxxqqq

  • 博客园
  • 联系
  • 订阅
  • 管理

2017年5月10日

optimal-account-balancing

摘要: 一群朋友去度假,有时互相借钱。 例如,爱丽丝为比尔的午餐支付了 10 美元。后来克里斯给爱丽丝 5 美元搭出租车。我们可以假设每笔交易为一个三元组(X,Y,Z),这意味着第 X 个人借给第 Y 个人 Z 美元。假设 Alice,Bill 和 Chris 是第0,1,2 个人(0,1,2是他们的ID) 阅读全文

posted @ 2017-05-10 15:43 xxxqqq 阅读(244) 评论(0) 推荐(0)

TreeSet VS HashSet VS LinkedHashSet; TreeMap VS HashMap VS LinkedHashMap

摘要: From online resources Set HashSet is much faster than TreeSet (constant-time versus log-time for most operations like add, remove and contains) but of 阅读全文

posted @ 2017-05-10 15:35 xxxqqq 阅读(179) 评论(0) 推荐(0)

Triangle Count

摘要: Given an array of integers, how many three numbers can be found in the array, so that we can build an triangle whose three edges length is the three n 阅读全文

posted @ 2017-05-10 15:29 xxxqqq 阅读(267) 评论(0) 推荐(0)

Reverse Pairs

摘要: For an array A, if i < j, and A [i] > A [j], called (A [i], A [j]) is a reverse pair. return total of reverse pairs in A. Example Given A = [2, 4, 1, 阅读全文

posted @ 2017-05-10 15:23 xxxqqq 阅读(241) 评论(0) 推荐(0)

Move Zeroes

摘要: Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Notice You must 阅读全文

posted @ 2017-05-10 15:22 xxxqqq 阅读(307) 评论(0) 推荐(0)

Intersection of Two Arrays II

摘要: Given two arrays, write a function to compute their intersection. Example Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. 利用较小的数组建m(下面代码并没有 阅读全文

posted @ 2017-05-10 15:20 xxxqqq 阅读(184) 评论(0) 推荐(0)

Intersection of Two Arrays

摘要: Given two arrays, write a function to compute their intersection. Example Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. 利用较小的数组建set 节省空间 1 p 阅读全文

posted @ 2017-05-10 15:17 xxxqqq 阅读(280) 评论(0) 推荐(0)

Create Maximum Number

摘要: Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. Th 阅读全文

posted @ 2017-05-10 15:13 xxxqqq 阅读(183) 评论(0) 推荐(0)

Coin Change

摘要: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee 阅读全文

posted @ 2017-05-10 15:09 xxxqqq 阅读(218) 评论(0) 推荐(0)

Backpack VI

摘要: Given an integer array nums with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer ta 阅读全文

posted @ 2017-05-10 15:05 xxxqqq 阅读(143) 评论(0) 推荐(0)

Add Digits

摘要: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. Example Given num = 38. The process is like: 3 + 阅读全文

posted @ 2017-05-10 15:02 xxxqqq 阅读(237) 评论(0) 推荐(0)

Maximum Average Subarray

摘要: Given an array with positive and negative numbers, find the maximum average subarray which length should be greater or equal to given length k. Exampl 阅读全文

posted @ 2017-05-10 14:58 xxxqqq 阅读(288) 评论(0) 推荐(0)

Binary Tree Maximum Node

摘要: Find the maximum node in a binary tree, return the node. Example Given a binary tree: 1 / \ -5 2 / \ / \ 0 3 -4 -5 return the node with value 3. 1 pub 阅读全文

posted @ 2017-05-10 14:56 xxxqqq 阅读(181) 评论(0) 推荐(0)

Convert BST to Greater Tree

摘要: Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all 阅读全文

posted @ 2017-05-10 14:54 xxxqqq 阅读(175) 评论(0) 推荐(0)

Guess Number Game

摘要: We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron 阅读全文

posted @ 2017-05-10 14:45 xxxqqq 阅读(1116) 评论(0) 推荐(0)

String Permutation

摘要: Given two strings, write a method to decide if one is a permutation of the other. Example abcd is a permutation of bcad, but abbe is not a permutation 阅读全文

posted @ 2017-05-10 14:39 xxxqqq 阅读(177) 评论(0) 推荐(0)

Binary Tree Path Sum

摘要: Given a binary tree, find all paths that sum of the nodes in the path equals to a given number target. A valid path is from root node to any of the le 阅读全文

posted @ 2017-05-10 14:36 xxxqqq 阅读(154) 评论(0) 推荐(0)

Convert Binary Search Tree to Doubly Linked List

摘要: Convert a binary search tree to doubly linked list with in-order traversal. Example Given a binary search tree: 4 / \ 2 5 / \ 1 3 return 1<->2<->3<->4 阅读全文

posted @ 2017-05-10 14:35 xxxqqq 阅读(190) 评论(0) 推荐(0)

Toy Factory

摘要: Factory is a design pattern in common usage. Please implement a ToyFactory which can generate proper toy based on the given type. Example ToyFactory t 阅读全文

posted @ 2017-05-10 13:58 xxxqqq 阅读(373) 评论(0) 推荐(0)

Singleton

摘要: Singleton is a most widely used design pattern. If a class has and only has one instance at every moment, we call this design as singleton. For exampl 阅读全文

posted @ 2017-05-10 13:55 xxxqqq 阅读(309) 评论(0) 推荐(0)

Find the Missing Number II

摘要: Giving a string with number from 1-n in random order, but miss 1 number.Find that number. Notice n <= 30 Example Given n = 20, str = 19201234567891011 阅读全文

posted @ 2017-05-10 13:47 xxxqqq 阅读(306) 评论(0) 推荐(0)

Edit Distance II

摘要: Given two strings S and T, determine if they are both one edit distance apart. Example Given s = "aDb", t = "adb" return true Given s = "aDb", t = "ad 阅读全文

posted @ 2017-05-10 13:38 xxxqqq 阅读(280) 评论(0) 推荐(0)

Edit Distance

摘要: 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 阅读全文

posted @ 2017-05-10 13:30 xxxqqq 阅读(159) 评论(0) 推荐(0)

House Robber III

摘要: The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each hou 阅读全文

posted @ 2017-05-10 13:23 xxxqqq 阅读(131) 评论(0) 推荐(0)

House Robber II

摘要: After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This t 阅读全文

posted @ 2017-05-10 13:16 xxxqqq 阅读(246) 评论(0) 推荐(0)

House Robber

摘要: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文

posted @ 2017-05-10 13:08 xxxqqq 阅读(253) 评论(0) 推荐(0)

strStr

摘要: For a given source string and a target string, you should output the first index(from 0) of target string in source string. If target does not exist i 阅读全文

posted @ 2017-05-10 13:02 xxxqqq 阅读(287) 评论(0) 推荐(0)

Flatten Nested List Iterator

摘要: Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list -- whose elements may also be integ 阅读全文

posted @ 2017-05-10 12:35 xxxqqq 阅读(183) 评论(0) 推荐(0)

 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3