摘要: 1.题目描述: 某软件用户共m个人,编号为0~m-1,用r[i][j]表示用户i和j的好友关系,r[i][j]=0说明不是好友,r[i][j]=1~9数值越大关系越好。其次,r[i][j] = r[j][i]。找出i的n度好友。若不存在n度好友则输出-1. 1度好友代表直接好友,2度好友代表好友的好 阅读全文
posted @ 2019-08-15 17:24 lpomeloz 阅读(1465) 评论(0) 推荐(0) 编辑
摘要: 遍历字符串时分三种情况讨论当前字符: 1. 若左括号,直接压入栈(该栈主要实现括号匹配即括号内的子串的重复) 2.若右括号,则弹出最近左括号之间的子串,且重复该子串。 3.若为字母,判断是否为重复字母,若是,则重复该字母。 且,对于每次重复完成的串,应判断是否还存在左括号,若存在则当前子串属于要继续 阅读全文
posted @ 2019-08-03 21:42 lpomeloz 阅读(548) 评论(0) 推荐(0) 编辑
摘要: Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be 阅读全文
posted @ 2019-07-09 21:03 lpomeloz 阅读(178) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an inte 阅读全文
posted @ 2019-07-08 19:16 lpomeloz 阅读(192) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may a 阅读全文
posted @ 2019-07-01 13:08 lpomeloz 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n  阅读全文
posted @ 2019-07-01 09:12 lpomeloz 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings consists of lowercase English letters only and the 阅读全文
posted @ 2019-06-30 17:29 lpomeloz 阅读(174) 评论(0) 推荐(0) 编辑
摘要: Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example, given a 3-ary tree: 阅读全文
posted @ 2019-06-30 16:25 lpomeloz 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] 阅读全文
posted @ 2019-06-30 16:22 lpomeloz 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between i and jequals 阅读全文
posted @ 2019-06-27 21:00 lpomeloz 阅读(147) 评论(0) 推荐(0) 编辑