├── .gitattributes ├── Dividers3 └── main.java ├── FizzBuzz └── FizzBuzz.py ├── README.md ├── Recyclable and Low Fat Products └── test.sql ├── Remove └── remove.py ├── SmallestMultiply └── main.java ├── palindrome └── palindrome.py ├── prefix └── prefix.py ├── romantoNumbers └── roman_number.py ├── shauffle └── shauffle.py └── validPoints └── validPoints.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Dividers3/main.java: -------------------------------------------------------------------------------- 1 | package Dividers3; 2 | 3 | public class main { 4 | public static void main(String[] args) { 5 | isThree(5); 6 | } 7 | 8 | static public boolean isThree(int n) { 9 | 10 | int count = 1; 11 | for (int i = 1; i <= n / 2; i++) { 12 | if (n % i == 0) { 13 | count++; 14 | } 15 | } 16 | if (count == 3) { 17 | return true; 18 | } else { 19 | return false; 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /FizzBuzz/FizzBuzz.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1FarZ1/Leetcode/666d486fc3e18a0c37dbf41b7233947500d921e9/FizzBuzz/FizzBuzz.py -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # leetcode_codes 2 | A Repo That Contains Solutions To Leet Code Problem I Solved 3 | -------------------------------------------------------------------------------- /Recyclable and Low Fat Products/test.sql: -------------------------------------------------------------------------------- 1 | 2 | SELECT * 3 | FROM Products 4 | Where low_fats ="Y" 5 | and recyclable ="Y" -------------------------------------------------------------------------------- /Remove/remove.py: -------------------------------------------------------------------------------- 1 | ## my algoritheme 2 | 3 | class Solution(object): 4 | def search(self, nums, target): 5 | for i in nums: 6 | if i==target: 7 | return nums.index(target) 8 | return -1 9 | 10 | 11 | print(removeDuplicates([1,1,2])) 12 | 13 | 14 | ### binary search algoritheme 15 | class Solution(object): 16 | def search(self, nums, target): 17 | low, high = 0, len(nums) - 1 18 | while(low <= high): 19 | mid = (low + (high - low)//2) 20 | if nums[mid] == target: 21 | return mid 22 | elif nums[mid] < target: 23 | low = mid + 1 24 | else: 25 | high = mid - 1 26 | return -1 27 | 28 | 29 | ## another solution 30 | class Solution: 31 | def search(self, nums, target): 32 | start = 0 33 | end = len(nums) - 1 34 | while start <= end: 35 | mid = (start + end) // 2 36 | if nums[mid] < target: 37 | start = mid + 1 38 | elif nums[mid] > target: 39 | end = mid - 1 40 | else: 41 | return mid 42 | return - -------------------------------------------------------------------------------- /SmallestMultiply/main.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int smallestEvenMultiple(int n) { 3 | 4 | int i=n; 5 | while(true){ 6 | if(i % 2==0){ 7 | return i; 8 | } 9 | i=i+n; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /palindrome/palindrome.py: -------------------------------------------------------------------------------- 1 | ## so this an algoritheme to check if given input string is palindrom 2 | class Solution(object): 3 | def isPalindrome(self,x): 4 | if list(str(x))[::-1] == list(str(x)): 5 | return True 6 | else : 7 | return False 8 | -------------------------------------------------------------------------------- /prefix/prefix.py: -------------------------------------------------------------------------------- 1 | ## this a algoritheme to get the common prefix of a list of string inputs 2 | 3 | def longestCommonPrefix(strs): 4 | x="" 5 | for i in strs: 6 | if i=="": 7 | return "" 8 | for i in range(len(strs[0])): 9 | first=strs[0] 10 | trouve=True 11 | for j in strs[1:]: 12 | 13 | if i < len(j): 14 | if j[i] != first[i]: 15 | trouve =False 16 | else: 17 | trouve=False 18 | if trouve==True: 19 | x+=strs[0][i] 20 | 21 | else: 22 | return x 23 | 24 | return x 25 | 26 | 27 | 28 | 29 | print(longestCommonPrefix( ["ab","a"])) -------------------------------------------------------------------------------- /romantoNumbers/roman_number.py: -------------------------------------------------------------------------------- 1 | ## THIS is algoritheme to convert a romen number to integer 2 | 3 | def romanToInt(s): 4 | roman = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000,'IV':4,'IX':9,'XL':40,'XC':90,'CD':400,'CM':900} 5 | mylist=[] 6 | i=0 7 | while i