ICode9

精准搜索请尝试: 精确搜索
  • C#应用程序文件类型2022-02-20 20:31:51

    c#应用程序称为解决方案(solution),可以由一个或多个项目组成。c#应用程序创建的文件类型及其说明如下图

  • 腾讯五十题 No.46 反转字符串2022-02-09 18:33:25

    题目链接 class Solution { public void reverseString(char[] s) { int l = 0; int r = s.length - 1; while(l<r){ s[l] ^= s[r];//s[l] = a^b s[r] ^= s[l];//s[r] = b^a^b = a; s[l] ^= s[r];//s[l] = a^

  • 腾讯五十题 No.41 2的幂2022-02-09 15:05:41

    题目链接 class Solution { public boolean isPowerOfTwo(int n) { if(n<=0) return false; //8的二进制1000 7的二进制0111 做个与操作结果为零 if((n&n-1)==0) return true; else return false; } }

  • 合并有序数组2022-02-08 17:00:13

    class Solution: #参数A:有序整数数组A #参数B:有序整数数组B #返回:一个新的有序整数数组 def merge(self, A, B): i,j = 0,0 c=[] while i<len(A) and j<len(B): if A[i]<B[j]: c.append(A[i]) i+=1 else:

  • 刷题072022-02-07 22:02:36

    贪心的本质是选择每一阶段的局部最优,从而达到全局最优 贪心没有套路,说白了就是常识性推导加上举反例。 贪心算法一般分为如下四步: 将问题分解为若干个子问题 找出适合的贪心策略 求解每一个子问题的最优解 将局部最优解堆叠成全局最优解 分发饼干 class Solution { public

  • 腾讯五十题 No.26 买卖股票的最佳时机2022-02-07 21:03:07

    题目链接 class Solution { public int maxProfit(int[] prices) { if(prices.length <= 1) return 0; int low = prices[0],res = 0; for(int i=1;i<prices.length;i++){ low = Math.min(low,prices[i]);

  • 2022-2-6数学day12022-02-06 19:34:22

    题1: 204. 计数质数 统计所有小于非负整数 n 的质数的数量。   示例 1: 输入:n = 10 输出:4 解释:小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7 。 示例 2: 输入:n = 0 输出:0 示例 3: 输入:n = 1 输出:0   提示: 0 <= n <= 5 * 106 1 class Solution { 2 public int c

  • LeetCode 1748. 唯一元素的和2022-02-06 15:03:52

    1748. 唯一元素的和 Solution 思路:看值域范围非常小,可以直接数组存值,就数组记录出现次数即可。 class Solution { public int sumOfUnique(int[] nums) { int len = nums.length; int[] cnt = new int[100 + 1]; for (int i = 1; i <= 100; i++) {

  • 【LeetCode】713. 乘积小于K的子数组2022-02-05 19:33:49

    class Solution { public: int numSubarrayProductLessThanK(vector<int>& nums, int k) { if(k<2) return 0; int n = nums.size(); int i=0,j=0; int product=1,ans=0; while(j<n) {

  • 腾讯五十题 No.7 盛水最多的容器2022-02-05 12:01:14

    题目链接 左右指针,不知道为什么挺慢的4ms public class Solution { public int maxArea(int[] height) { //定义左右指针 int l = 0,r = height.length-1; int ans = 0; while(l<r){ //找最大值 int tmp = Math.min(heigh

  • 腾讯五十题 No.6 回文数2022-02-05 11:33:27

    题目链接 easy题,没有奇奇怪怪的条件限制 class Solution{ public boolean isPalindrome(int x){ if(x<0) return false; //if(x<10) return true; int num = x; int ans = 0; while(x != 0){ ans =ans*10 + x%10;

  • 题目翻译(18)2022-02-05 10:33:56

    Sumsets(http://noi.openjudge.cn/ch0305/1551/) 描述 Given S, a set of integers, find the largest d such that a + b + c = d where a, b, c, and d are distinct elements of S. 输入 Several S, each consisting of a line containing an integer 1 <= n <= 1000 ind

  • 231. 2 的幂(c++)2022-02-04 22:02:16

    循环 class Solution { public: bool isPowerOfTwo(int n) { for(int i = 0; i <= 31; i++){ if(pow(2,i) == n){ return true; } } return false; } }; class Solution { public: bool

  • 力扣Day232022-02-04 20:59:21

    283、移动零 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 请注意 ,必须在不复制数组的情况下原地对数组进行操作。   class Solution { public void moveZeroes(int[] nums) { int slow=0,fast=0; for(int i=0;i<

  • Submit solution(1200)2022-02-04 14:02:54

    #include<bits/stdc++.h> using namespace std; int n,k; int main(){ int t; cin>>t; while(t--){ scanf("%d %d",&n,&k); if(n%4==0){ printf("%d %d %d\n",n/2,n/4,n/4); }

  • Submit solution(1100)2022-02-04 11:35:07

    #include<bits/stdc++.h> #define ll long long using namespace std; ll hc,hm,k,w,a,d,h,dc,dm,t; bool flag; void rec(){ } int main(){ cin>>t; while(t--){ flag=0; scanf("%lld %lld",&hc,&dc); s

  • 50. Pow(x, n)2022-02-04 05:00:43

    This problem is very easy to solve if using bruteforece solution, the time complexity is O(n). public double myPow(double x, int n) { if (n == 0) return 1; double res = 1; int m = Math.abs(n); for (int i =

  • 杨辉三角2022-02-03 21:33:47

    参考:https://leetcode-cn.com/u/leetcode-solution

  • 刷题032022-02-03 12:33:51

    移除元素 class Solution { public int removeElement(int[] nums, int val) { int slow=0; int fast=0; for(fast=0;fast<nums.length;fast++) { if(nums[fast]!=val) { nums[slow++]=nums[fast

  • Solution - P72042022-02-02 23:04:07

    题目传送门 Solution. 我们首先发现答案是具有单调性的:砸的雪球越多构成「完美单词」的机率就越大。所有我们可以进行二分答案。 然后在 check 里面进行的操作有如下几种: 统计单词序列中每个单词出现的次数 删除位置在 \(1 \sim x\) 的字母( \(x\) 为二分的咋的雪球数量) 判断区间

  • 反转字符串 Java2022-02-01 16:35:39

    力扣题目链接 位运算 class Solution { public void reverseString(char[] s) { int l = 0; int r = s.length - 1; while(l<r){ s[l] ^= s[r];//s[l] = a^b s[r] ^= s[l];//s[r] = b^a^b = a; s[l] ^= s[r];//s

  • 斐波那契数2022-02-01 13:04:05

    斐波那契数 class Solution { public int fib(int n) { if (n < 2) return n; int p = 0, q = 0, ans = 1; //滑动数组 for (int i = 2; i <= n; i ++) { p = q; q = ans; ans = p

  • 每日一练-数组中的重复数字2022-01-31 20:35:11

    对于此类问题来说,我们可以考虑使用哈希表来进行求解,如果使用哈希表,那么我们可以得到代码如下: class Solution { public: int findRepeatNumber(vector<int>& nums) { unordered_map<int,int>map; for(int i = 0;i<nums.size();++i){ if(map[nums[i] > 0){

  • 【算法】力扣第 277 场周赛2022-01-30 13:00:09

    文章目录 [2148. 元素计数](https://leetcode-cn.com/problems/count-elements-with-strictly-smaller-and-greater-elements/)[2149. 按符号重排数组](https://leetcode-cn.com/problems/rearrange-array-elements-by-sign/)[2150. 找出数组中的所有孤独数字](https://lee

  • 字符串中找到第一个只出现一次的字符2022-01-28 16:27:49

    '''在一个长为a字符串中找到第一个只出现一次的字符,并返回它的位置, 如果没有则返回 -1(需要区分大小写).(从0开始计数)'''class Solution: def FirstNotRepeatingChar(self, s): temp = OrderedDict() for i in s: if i not in temp: te

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有