For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Counting Bits - Bit manipulation | |
| // Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i. | |
| // Example 1: | |
| // Input: n = 2 | |
| // Output: [0,1,1] | |
| // Explanation: | |
| // 0 --> 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Question 7 - Dynamic programming | |
| // Given an integer array nums, handle multiple queries of the following type: | |
| // Calculate the sum of the elements of nums between indices left and right inclusive where left <= right. | |
| // Implement the NumArray class: | |
| // NumArray(int[] nums) Initializes the object with the integer array nums. | |
| // int sumRange(int left, int right) Returns the sum of the elements of nums between indices left and right inclusive (i.e. nums[left] + nums[left + 1] + ... + nums[right]). | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Question 1: | |
| // Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. | |
| // Example 1: | |
| // Input: nums = [1,2,3,1] | |
| // Output: true | |
| // Example 2: | |
| // Input: nums = [1,2,3,4] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Problem 6 | |
| /* | |
| You are given an array prices where prices[i] is the price of a given stock on the ith day. | |
| You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. | |
| Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. | |
| Example 1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| final solution = Solution(); | |
| String s = "abcabcbb"; | |
| final result = solution.lengthOfLongestSubstring(s); | |
| print(result); | |
| } | |
| /* | |
| * Given a string s, find the length of the longest substring without repeating characters. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| final solution = Solution(); | |
| final result = solution.climbStairs(5); | |
| print(result); | |
| } | |
| /* | |
| * | |
| You are climbing a staircase. It takes n steps to reach the top. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| final solution = Solution(); | |
| List<int> nums = [4, 1, 2, 1, 2]; | |
| final result = solution.singleNumber(nums); | |
| print(result); | |
| } | |
| /* | |
| Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| final solution = Solution(); | |
| List<int> nums = [1,1]; | |
| final result = solution.findDisappearedNumbers(nums); | |
| print(result); | |
| } | |
| //Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. | |
| Example 1: | |
| Input: nums = [3,0,1] | |
| Output: 2 | |
| Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums. | |
| Example 2: |
NewerOlder