首页 > TAG信息列表 > indice

LeetCode #1252. Cells with Odd Values in a Matrix

题目 1252. Cells with Odd Values in a Matrix 解题方法 先构造这么一个矩阵出来,在构造的过程中判断当前位置是否为奇数,如果是就把总数+1,如果不是就把总数-1,最后返回奇数的总数。 时间复杂度:O(L(m+n)),L是indices的长度 空间复杂度:O(mn) 代码 class Solution: def oddCells(

刷题笔记-两数之和

题目描述 https://leetcode-cn.com/problems/two-sum/ 我的解答 最粗暴的方式,遍历输入vector中所有的数字。 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> indice; int i, j; for(i=0; i<nums.s

leetcode 1 Two Sum

题目内容 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15]