0%

英文原题

Given a list of strings words and a string pattern, return a list of words[i] that match pattern. You may return the answer in any order.

A word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the pattern with p(x), we get the desired word.

Recall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no two letters map to the same letter.

阅读全文 »

英文原题

The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.

Given an integer n, return all distinct solutions to the n-queens puzzle.

Each solution contains a distinct board configuration of the n-queens’ placement, where ‘Q’ and ‘.’ both indicate a queen and an empty space, respectively.

阅读全文 »

    这一期总结一下tab bar 的使用。tab bar是做app经常会用到的一种结构,做出来的效果就类似微信下面的那个有聊天、联系人、发现、我,几块的这种,可以让用户一目了然,知道这个app有哪些主要功能。     先进到main.storyboard里面,可以发现默认的是一个单独的viewcontroller。我们到库里,找到tab bar controller,把它拖出来,并且删掉后面连带的那两个view controller。 tab bar1 tab bar2 选中 Tab Bar Controller 进到属性检查(attributes inspector) 把 is initial view controller 这个勾上。 tab bar3     接下来为了把我们的 view controller 放到这个 tab bar controller 里面,要把 view controller embed 到 navigation controller 里面,如图。(其实这么做也是为了美观让app显得更一体化,要是直接把view controller连上去也可以) tab bar4 tab bar5     最后选中Tab Bar Controller 按住 control,蓝线一直拖到 Navigation Controller 那,选择 view controllers。这样就把 view controller 和 tab view controller 连接到一起了。 tab bar6

英文原题

Given a list of words, each word consists of English lowercase letters.

Let’s say word1 is a predecessor of word2 if and only if we can add exactly one letter anywhere in word1 to make it equal to word2. For example, “abc” is a predecessor of “abac”.

A word chain is a sequence of words [word_1, word_2, …, word_k] with k >= 1, where word_1 is a predecessor of word_2, word_2 is a predecessor of word_3, and so on.

Return the longest possible length of a word chain with words chosen from the given list of words.

阅读全文 »

英文原题

Given a binary tree, we install cameras on the nodes of the tree.

Each camera at a node can monitor its parent, itself, and its immediate children.

Calculate the minimum number of cameras needed to monitor all nodes of the tree.

阅读全文 »

英文原题

There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints.

In one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards.

Your score is the sum of the points of the cards you have taken.

Given the integer array cardPoints and the integer k, return the maximum score you can obtain.

阅读全文 »

英文原题

Given an array of integers target. From a starting array, A consisting of all 1’s, you may perform the following procedure :

  • let x be the sum of all elements currently in your array.
  • choose index i, such that 0 <= i < target.size and set the value of A at index i to x.
  • You may repeat this procedure as many times as needed.

Return True if it is possible to construct the target array from A otherwise return False.

阅读全文 »