Skip to content

Instantly share code, notes, and snippets.

View Ayoush's full-sized avatar
:octocat:
If it's not gonna work,it is worth a try.

Ayoush Chourasia Ayoush

:octocat:
If it's not gonna work,it is worth a try.
  • Pune
View GitHub Profile
@Ayoush
Ayoush / two_sum.py
Created November 21, 2023 05:54
two sum
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
@Ayoush
Ayoush / valid_anagram.py
Created November 21, 2023 05:26
anagram
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]]
@Ayoush
Ayoush / contains_duplicate.py
Created November 21, 2023 05:12
contains_duplicate
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
defmodule OtpConceptsProcesses do
use GenServer
def start_link() do
GenServer.start_link(__MODULE__, :ok, [])
end
def init(:ok) do
{:ok, %{}}
end
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)
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))
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
#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
#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
#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