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
| class Solution(object): | |
| def twoSum(self, nums, target): | |
| hash_map = {} | |
| for i in range(len(nums)): | |
| ans = target - nums[i] | |
| if ans in hash_map.keys(): | |
| return([hash_map[ans], i]) | |
| hash_map[nums[i]] = i | |
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
| def isAnagram(s, t): | |
| if len(s) != len(t): | |
| return False | |
| s_hash = [] | |
| t_hash = [] | |
| for i in range(0, len(s)): | |
| if s[i] in t_hash: | |
| t_hash.remove(s[i]) | |
| else: | |
| s_hash = s_hash + [s[i]] |
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
| def containsDuplicate(self, nums): | |
| if len(nums) == 1: | |
| return False | |
| nums.sort() | |
| for i in range(1, len(nums)): | |
| if nums[i-1] == nums[i]: | |
| return True | |
| return False |
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
| defmodule OtpConceptsProcesses do | |
| use GenServer | |
| def start_link() do | |
| GenServer.start_link(__MODULE__, :ok, []) | |
| end | |
| def init(:ok) do | |
| {:ok, %{}} | |
| end |
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
| Enum.reduce(params, dynamic(true), fn | |
| {"workspace_id", workspace_id}, dynamic_query -> | |
| dynamic( | |
| [task, project, user_task, time_track], | |
| ^dynamic_query and project.workspace_id == ^workspace_id | |
| ) | |
| {"user_ids", user_ids}, dynamic_query -> | |
| user_ids = Enum.map(String.split(user_ids, ","), fn x -> String.to_integer(x) end) |
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
| query = | |
| Task | |
| |> join(:inner, [task], project in Project, on: project.id == task.project_id) | |
| |> join(:inner, [task], user_task in UserTask, on: task.id == user_task.task_id) | |
| |> join(:left, [task], time_track in TimeTracking, on: time_track.task_id == task.id) | |
| |> where(^filter_for_tasks_for_criteria(params)) |
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
| int main() | |
| { | |
| { | |
| int x = 10, y = 20; | |
| { | |
| // The outer block contains declaration of x and y, so | |
| // following statement is valid and prints 10 and 20 | |
| printf("x = %d, y = %d\n", x, y); | |
| { | |
| // y is declared again, so outer block y is not accessible |
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
| #include <stdio.h> | |
| #include <string.h> //strlen | |
| #include <stdlib.h> //strlen | |
| #include <sys/socket.h> | |
| #include <arpa/inet.h> //inet_addr | |
| #include <unistd.h> //write | |
| #include <pthread.h> //for threading , link with lpthread | |
| #define MAX 10000 | |
| //the thread function |
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
| #include <netdb.h> //bzero() | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| #include <sys/socket.h> //socket() | |
| #include <arpa/inet.h> //inet_addr | |
| #include <unistd.h> //write | |
| #include <pthread.h> //for threading , link with lpthread | |
| #define MAX 10000 |
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
| #include <stdio.h> //for printf() and scanf() | |
| #include <sys/types.h> | |
| #include <sys/socket.h>//for socket connect send and recieve | |
| #include <netinet/in.h> | |
| #include <unistd.h>//for close() | |
| #include <netdb.h> | |
| #include <fcntl.h> | |
| #include <stdlib.h>//for atoi() | |
| #include <string.h>//for memeset |
NewerOlder