This file contains 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
class MedianFinder: | |
def __init__(self): | |
self.data = [] | |
def addNum(self, num: int) -> None: | |
bisect.insort(self.data, num) | |
def findMedian(self) -> float: | |
data_length = len(self.data) |
This file contains 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
public class Solution { | |
public int RemoveDuplicates(int[] nums) { | |
if (nums.Length == 0) | |
return 0; | |
var currentModifiableIndex = 1; | |
var lastModifiedValue = nums[0]; | |
for (var i = 0; i < nums.Length; i++) { | |
var currentValue = nums[i]; |
This file contains 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
class Solution: | |
def removeDuplicates(self, nums: List[int]) -> int: | |
if len(nums) == 1: | |
return 1 | |
non_dupes_ptr = 1 | |
for num in nums: | |
if nums[non_dupes_ptr - 1] < num: | |
nums[non_dupes_ptr] = num |
This file contains 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
class Solution: | |
def removeDuplicates(self, s: str) -> str: | |
stack = [] | |
for char in s: | |
if stack and stack[-1] == char: | |
stack.pop() | |
else: | |
stack.append(char) |
This file contains 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
class Solution: | |
def depthSum(self, nestedList: List[NestedInteger]) -> int: | |
def depth_sum_recursive(current_item, depth): | |
if current_item.isInteger(): | |
return current_item.getInteger() * depth | |
return sum(depth_sum_recursive(item, depth + 1) for item in current_item.getList()) | |
return sum(depth_sum_recursive(item, 1) for item in nestedList) |
This file contains 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
class StockSpanner: | |
def __init__(self): | |
self.span_stack = [] | |
def next(self, price: int) -> int: | |
span = 1 | |
while self.span_stack and price >= self.span_stack[-1][0]: | |
span += self.span_stack.pop()[1] | |
This file contains 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
class Solution: | |
def makeGood(self, s: str) -> str: | |
if len(s) <= 1: | |
return s | |
stack = [] | |
for char in s: | |
if (stack and stack[-1] != char | |
and stack[-1].lower() == char.lower()): |
This file contains 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
#[user] | |
# name = Your Name | |
# email = youremail@example.com | |
[core] | |
autocrlf = true | |
excludesfile = C:\\Users\\Efrain\\Documents\\gitignore_global.txt | |
editor = 'C:/Program Files/Sublime Text 3/subl.exe' -n -w | |
ignorecase = false | |
[push] | |
default = simple |
This file contains 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
public class CustomerModel : ModelBase { | |
private string _customerName; | |
public string CustomerName { | |
get { return _customerName; } | |
set { SetProperty(ref _customerName, value); } | |
} | |
private int _orderCount; | |
public int OrderCount { | |
get { return _orderCount; } |
This file contains 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
Enumerable.Range(1, 30).Select(num => | |
((Func<string[], string>) | |
(buzz => new string[]{ | |
buzz[((num + 2) % 3) / 2] + | |
buzz[((num + 4) % 5) / 4 * 2], | |
""+num | |
}.First(r => r != "")))(new[] { null, "fizz", "buzz"}) | |
).ToList().ForEach(s => Console.WriteLine(s)); |
NewerOlder