链表中倒数第K个结点 牛客网 剑指Offer 题目描述 输入一个链表,输出该链表中倒数第k个结点. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: #run:33ms memory:5728k def FindKthToTail(self, head, k): if k<=0 or head == None: return None p = head ret…
链接:https://ac.nowcoder.com/acm/contest/884/K来源:牛客网 题目描述 300iq loves numbers who are multiple of 300. One day he got a string consisted of numbers. He wants to know how many substrings in the string are multiples of 300 when considered as decimal inte…
最小的K个数 牛客网 剑指Offer 题目描述 输入n个整数,找出其中最小的K个数.例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,. class Solution: #run:33ms memory:5732k def GetLeastNumbers_Solution(self, tinput, k): if tinput == None or len(tinput) < k or len(tinput) <= 0 or k <=0: return…
第K个数 牛客网 程序员面试金典 C++ Python 题目描述 有一些数的素因子只有3.5.7,请设计一个算法,找出其中的第k个数. 给定一个数int k,请返回第k个数.保证k小于等于100. 测试样例: 3 返回:7 C++ class KthNumber { public: //run:3ms memory:504k int findKth(int k){ vector<int> res(k+1,0); res[0] = 1; int t3 = 0; int t5 = 0; int t…
链接:https://ac.nowcoder.com/acm/contest/882/D来源:牛客网 Given a vertex-weighted graph with N vertices, find out the K-th minimum weighted clique. A subset of vertices of an undirected graph is called clique if and only if every two distinct vertices in th…