├── AddCharacter
├── README.md
├── Result.png
├── addCharacter.java
└── Question.txt
├── README.md
├── .DS_Store
├── Zoos
├── .DS_Store
├── Result.png
├── README.md
├── Zoos.c
├── ProblemStatement.txt
└── Zoos.java
├── Two Sum
├── Result.png
├── Problem Statement.docx
├── README.md
└── Solution.java
├── Fizz Buzz
├── Result.png
├── README.md
├── Question.txt
└── Solution.java
├── Good Turn
├── Result.png
├── README.md
├── Codechef.java
└── ProblemStatement.txt
├── Java List
├── Result.png
├── Problem Statement.pdf
├── README.md
└── Solution.java
├── Add Strings
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── Java Stack
├── Result.png
├── Problem Statement.pdf
├── README.md
└── Solution.java
├── Sort Colors
├── Result.png
├── README.md
├── code.java
├── Question.txt
└── Solution.java
├── Split houses
├── .DS_Store
├── Result.png
├── ProblemStatement.docx
├── README.md
└── Split_houses.c
├── Ugly Number
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── even_order
├── even.class
├── even.java
└── question.txt
├── Divisibility
├── Result.png
├── README.md
├── ProblemStatement.txt
└── Divisibility.java
├── Group Anagrams
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── Happy Number
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── Java Anagrams
├── Result.png
├── Problem Statement.pdf
├── README.md
├── WithInbuild.java
└── WithoutInbuild.java
├── Missing Number
├── Result.png
├── README.md
├── Readme.md
├── Solution.java
├── Question.txt
└── code.java
├── Ones and Zeros
├── Result.png
├── README.md
├── Kata.java
└── ProblemStatement.txt
├── Power of Four
├── Result.png
├── README.md
├── Solution.java
└── ProblemStatement.txt
├── Power of Three
├── Result.png
├── README.md
├── Solution.java
└── ProblemStatement.txt
├── Power of Two
├── Result.png
├── README.md
├── Solution.java
└── ProblemStatement.txt
├── Printer Errors
├── Result.png
├── README.md
├── Kata.java
└── ProblemStatement.txt
├── Single Number
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── Split Strings
├── Result.png
├── README.md
├── ProblemStatement.txt
└── Kata.java
├── Toggle String
├── Result.png
├── Problem Statement.docx
├── README.md
└── TestClass.java
├── Valid Braces
├── Result.png
├── README.md
├── ProblemStatement.txt
└── Kata.java
├── Water Bottles
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── Who likes it?
├── Result.png
├── README.md
├── ProblemStatement.txt
└── Kata.java
├── oddlyeven
├── oddlyeven.class
├── TCS Coding Question - 2.txt
└── oddlyeven.java
├── Candy in the box
├── Result.png
├── Problem Statement.docx
├── README.md
└── Solution.java
├── Climbing Stairs
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── Day of the Year
├── Result.png
├── README.md
├── ProblemStatement.txt
└── Solution.java
├── Maximum Subarray
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── PalindromicString
├── .DS_Store
├── Result.png
├── ProblemStatement.docx
├── README.md
└── PalindromicString.java
├── Pass The Pillow
├── Result.png
├── ProblemStatement.docx
├── README.md
└── Solution.java
├── Reverse Integer
├── Result.png
├── README.md
├── Question.txt
└── Solution.java
├── Roman to Integer
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── Valid Boomerang
├── Result.png
├── README.md
├── Question.txt
└── Solution.java
├── Valid Palindrome
├── Result.png
├── README.md
├── Problem Statement.txt
└── Solution.java
├── Contains Duplicate
├── Result.png
├── README.md
├── ProblemStatement.txt
└── Solution.java
├── Divide Two Integers
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── Find the Difference
├── Result.png
├── README.md
├── ProblemStatement.txt
└── Solution.java
├── Highest and Lowest
├── Result.png
├── README.md
├── ProblemStatement.txt
└── Kata.java
├── Is a number prime?
├── Result.png
├── README.md
├── Kata.java
└── ProblemStatement.txt
├── Length of Last Word
├── Result.png
├── Problem Statement.pdf
├── README.md
├── code.java
└── Solution.java
├── Linked List Cycle
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── String ends with?
├── Result.png
├── README.md
├── Kata.java
└── ProblemStatement.txt
├── Proportion Of Numbers
├── Result.png
├── Question.txt
└── Proportion.java
├── Sort Array By Parity
├── Result.png
├── README.md
├── Question.txt
└── Solution.java
├── Valid Perfect Square
├── Result.png
├── README.md
├── Solution.java
└── ProblemStatement.txt
├── prime_number
├── prime_number.class
├── problem_statement.txt
└── prime_number.java
├── Find The Parity Outlier
├── Result.png
├── README.md
├── ProblemStatement.txt
└── Kata.java
├── N-th Tribonacci Number
├── Result.png
├── README.md
├── Solution.java
└── ProblemStatement.txt
├── Roy and Profile Picture
├── Result.png
├── Problem Statement.docx
├── README.md
└── TestClass.java
├── Search Insert Position
├── Result.png
├── README.md
├── Question.txt
└── Solution.java
├── word_is_a_key
├── word_is_a_key.class
├── problem_statement.txt
└── word_is_a_key.java
├── Factorial Trailing Zeroes
├── Result.png
├── README.md
├── Solution.java
└── ProblemStatement.txt
├── Middle of the Linked List
├── Result.png
├── README.md
├── Question.txt
└── Solution.java
├── Reverse Words in a String
├── Result.png
├── README.md
├── Problem Statement.txt
└── Solution.java
├── sweet_seventeen
├── sweet_seventeen.class
├── TCS Coding Question - 5.txt
└── sweet_seventeen.java
├── Add to Array-Form of Integer
├── Result.png
├── README.md
├── Question.txt
└── Solution.java
├── Median of Two Sorted Arrays
├── Result.png
├── Problem Statement.docx
├── README.md
└── Solution.java
├── Student Attendance Record I
├── Result.png
├── Problem Statement.docx
├── README.md
└── Solution.java
├── geometric_series
├── geometric_series.class
├── geometric_series.java
└── question.txt
├── Ali and Helping innocent people
├── Result.png
├── Problem Statement.pdf
├── README.md
└── TestClass.java
├── Search in Rotated Sorted Array
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── Sum of All Odd Length Subarrays
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── Remove Duplicates from Sorted List
├── Result.png
├── README.md
├── Question.txt
└── Solution.java
├── To Lower Case
├── code.java
└── Readme.md
├── Categorize Box According to Criteria
├── Result.png
├── README.md
├── Solution.java
└── Question.txt
├── Pow(x,n)
├── Pow(x,n).java
└── README.md
├── Remove Duplicates from Sorted Array
├── Result.png
├── README.md
└── Solution.java
├── Remove Duplicates from Sorted List II
├── Result.png
├── README.md
├── Question.txt
└── Solution.java
├── Plus One
└── Readme.md
├── SortStringArrayCaseInSensitive
├── ProblemStatement.png
├── readMe.md
└── SortStringArrayCaseInSensitive.java
├── Convert Binary Number in a Linked List to Integer
├── Result.png
├── README.md
├── Question.txt
└── Solution.java
├── Find the Maximum Achievable Number
├── code.java
└── Readme.md
├── Tree Preorder Traversal
├── README.md
└── Tree Preorder Traversal.java
├── Java Regular expression
└── code.java
├── Convert the Temperature
├── code.java
└── Readme.md
├── Smallest Even Multiple
├── code.java
└── Readme.md
├── Rotate Image
├── Readme.md
└── code.txt
├── Jewels and Stones
├── Readme.md
└── code.java
├── Shuffle String
├── Readme.md
└── code.java
├── Sum Multiples
├── Readme.md
└── code.java
├── Truncate Sentence
├── Readme.md
└── code.java
├── Defanging an IP Address
├── Readme.md
└── code.java
├── Merge Sorted Array
├── Readme.md
└── code.java
├── Number of Good Pairs
├── Readme.md
└── code.java
├── Search a 2D Matrix
├── Readme.md
└── code.java
├── Set Matrix Zeroes
├── README.md
└── Set Matrix Zeroes.java
├── Sorting the Sentence
├── Readme.md
└── code.java
├── Valid Parantheses
├── README.md
└── Valid Parentheses.java
├── Encode and Decode TinyURL
├── Readme.md
└── code.java
├── Goal Parser Interpretation
├── Readme.md
└── code.java
├── Cells with Odd Values in a Matrix
├── Readme.md
└── code.java
├── A Number After a Double Reversal
├── Readme.md
└── code.java
├── Cells in a Range on an Excel Sheet
├── Readme.md
└── code.java
├── Account Balance After Rounded Purchase
├── Readme.md
└── code.java
├── Check if a String Is an Acronym of Words
├── Readme.md
└── code.java
├── Maximum Number of Words Found in Sentences
├── Readme.md
└── code.java
├── Pointers in C
├── README.md
└── Pointers in C.c
├── Check If Two String Arrays are Equivalent
├── Readme.md
└── code.java
├── Divisible and Non-divisible Sums Difference
├── Readme.md
└── code.java
├── Find the K-Beauty of a Number
├── Readme.md
└── code.java
├── Replace Elements with Greatest Element on Right Side
├── Readme.md
└── code.java
├── Final Value of Variable After Performing Operations
├── Readme.md
└── code.java
├── Find First and Last Position of Element in Sorted Array
├── README.md
└── Find First and Last Position of Element in Sorted Array.java
├── Number of Steps to Reduce a Number to Zero
├── Readme.md
└── code.java
├── Reverse_Vowels_of_a_String
├── README.md
└── Reverse_Vowels_of_a_String.java
├── Subtract the Product and Sum of Digits of an Integer
├── Readme.md
└── code.java
├── Difference Between Element Sum and Digit Sum of an Array
├── Readme.md
└── code.java
├── Flipping an Image
├── Readme.md
└── code.java
├── Array Reversal
├── README.md
└── Array Reversal.c
├── Longest Common Prefix
├── Readme.md
└── code.java
├── Integer to Roman
└── Readme.md
├── Java varargs simple addition
└── code.java
├── Java Static Intializer Block
└── code.java
├── Java Reflection - Attributes
└── code.java
├── Elements within Ranges
├── README.md
└── Solution.java
├── Sorting Algorithms
├── insertionSort.java
├── selectionSort.java
├── countingSort.java
├── bubbleSort.java
└── quickSort.java
├── matrix
├── matrix.java
└── problem-statement.txt
├── variadic functions
└── code.c
├── Compare Banks
└── Solution.java
└── Java Instanceof keyword
└── code.java
/AddCharacter/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Java-Basic
2 | # C - Basic
3 |
--------------------------------------------------------------------------------
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/.DS_Store
--------------------------------------------------------------------------------
/Zoos/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Zoos/.DS_Store
--------------------------------------------------------------------------------
/Zoos/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Zoos/Result.png
--------------------------------------------------------------------------------
/ Two Sum/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/ Two Sum/Result.png
--------------------------------------------------------------------------------
/Fizz Buzz/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Fizz Buzz/Result.png
--------------------------------------------------------------------------------
/Good Turn/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Good Turn/Result.png
--------------------------------------------------------------------------------
/Java List/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Java List/Result.png
--------------------------------------------------------------------------------
/Add Strings/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Add Strings/Result.png
--------------------------------------------------------------------------------
/Java Stack/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Java Stack/Result.png
--------------------------------------------------------------------------------
/Sort Colors/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Sort Colors/Result.png
--------------------------------------------------------------------------------
/Split houses/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Split houses/.DS_Store
--------------------------------------------------------------------------------
/Ugly Number/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Ugly Number/Result.png
--------------------------------------------------------------------------------
/even_order/even.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/even_order/even.class
--------------------------------------------------------------------------------
/AddCharacter/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/AddCharacter/Result.png
--------------------------------------------------------------------------------
/Divisibility/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Divisibility/Result.png
--------------------------------------------------------------------------------
/Group Anagrams/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Group Anagrams/Result.png
--------------------------------------------------------------------------------
/Happy Number/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Happy Number/Result.png
--------------------------------------------------------------------------------
/Java Anagrams/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Java Anagrams/Result.png
--------------------------------------------------------------------------------
/Missing Number/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Missing Number/Result.png
--------------------------------------------------------------------------------
/Ones and Zeros/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Ones and Zeros/Result.png
--------------------------------------------------------------------------------
/Power of Four/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Power of Four/Result.png
--------------------------------------------------------------------------------
/Power of Three/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Power of Three/Result.png
--------------------------------------------------------------------------------
/Power of Two/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Power of Two/Result.png
--------------------------------------------------------------------------------
/Printer Errors/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Printer Errors/Result.png
--------------------------------------------------------------------------------
/Single Number/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Single Number/Result.png
--------------------------------------------------------------------------------
/Split Strings/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Split Strings/Result.png
--------------------------------------------------------------------------------
/Split houses/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Split houses/Result.png
--------------------------------------------------------------------------------
/Toggle String/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Toggle String/Result.png
--------------------------------------------------------------------------------
/Valid Braces/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Valid Braces/Result.png
--------------------------------------------------------------------------------
/Water Bottles/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Water Bottles/Result.png
--------------------------------------------------------------------------------
/Who likes it?/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Who likes it?/Result.png
--------------------------------------------------------------------------------
/oddlyeven/oddlyeven.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/oddlyeven/oddlyeven.class
--------------------------------------------------------------------------------
/Candy in the box/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Candy in the box/Result.png
--------------------------------------------------------------------------------
/Climbing Stairs/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Climbing Stairs/Result.png
--------------------------------------------------------------------------------
/Day of the Year/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Day of the Year/Result.png
--------------------------------------------------------------------------------
/Maximum Subarray/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Maximum Subarray/Result.png
--------------------------------------------------------------------------------
/PalindromicString/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/PalindromicString/.DS_Store
--------------------------------------------------------------------------------
/Pass The Pillow/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Pass The Pillow/Result.png
--------------------------------------------------------------------------------
/Reverse Integer/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Reverse Integer/Result.png
--------------------------------------------------------------------------------
/Roman to Integer/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Roman to Integer/Result.png
--------------------------------------------------------------------------------
/Valid Boomerang/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Valid Boomerang/Result.png
--------------------------------------------------------------------------------
/Valid Palindrome/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Valid Palindrome/Result.png
--------------------------------------------------------------------------------
/Contains Duplicate/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Contains Duplicate/Result.png
--------------------------------------------------------------------------------
/Divide Two Integers/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Divide Two Integers/Result.png
--------------------------------------------------------------------------------
/Find the Difference/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Find the Difference/Result.png
--------------------------------------------------------------------------------
/Highest and Lowest/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Highest and Lowest/Result.png
--------------------------------------------------------------------------------
/Is a number prime?/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Is a number prime?/Result.png
--------------------------------------------------------------------------------
/Length of Last Word/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Length of Last Word/Result.png
--------------------------------------------------------------------------------
/Linked List Cycle/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Linked List Cycle/Result.png
--------------------------------------------------------------------------------
/PalindromicString/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/PalindromicString/Result.png
--------------------------------------------------------------------------------
/String ends with?/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/String ends with?/Result.png
--------------------------------------------------------------------------------
/ Two Sum/Problem Statement.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/ Two Sum/Problem Statement.docx
--------------------------------------------------------------------------------
/Java List/Problem Statement.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Java List/Problem Statement.pdf
--------------------------------------------------------------------------------
/Java Stack/Problem Statement.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Java Stack/Problem Statement.pdf
--------------------------------------------------------------------------------
/Proportion Of Numbers/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Proportion Of Numbers/Result.png
--------------------------------------------------------------------------------
/Sort Array By Parity/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Sort Array By Parity/Result.png
--------------------------------------------------------------------------------
/Valid Perfect Square/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Valid Perfect Square/Result.png
--------------------------------------------------------------------------------
/prime_number/prime_number.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/prime_number/prime_number.class
--------------------------------------------------------------------------------
/Find The Parity Outlier/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Find The Parity Outlier/Result.png
--------------------------------------------------------------------------------
/Java Anagrams/Problem Statement.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Java Anagrams/Problem Statement.pdf
--------------------------------------------------------------------------------
/N-th Tribonacci Number/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/N-th Tribonacci Number/Result.png
--------------------------------------------------------------------------------
/Roy and Profile Picture/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Roy and Profile Picture/Result.png
--------------------------------------------------------------------------------
/Search Insert Position/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Search Insert Position/Result.png
--------------------------------------------------------------------------------
/Split houses/ProblemStatement.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Split houses/ProblemStatement.docx
--------------------------------------------------------------------------------
/word_is_a_key/word_is_a_key.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/word_is_a_key/word_is_a_key.class
--------------------------------------------------------------------------------
/Factorial Trailing Zeroes/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Factorial Trailing Zeroes/Result.png
--------------------------------------------------------------------------------
/Middle of the Linked List/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Middle of the Linked List/Result.png
--------------------------------------------------------------------------------
/Pass The Pillow/ProblemStatement.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Pass The Pillow/ProblemStatement.docx
--------------------------------------------------------------------------------
/Reverse Words in a String/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Reverse Words in a String/Result.png
--------------------------------------------------------------------------------
/Toggle String/Problem Statement.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Toggle String/Problem Statement.docx
--------------------------------------------------------------------------------
/sweet_seventeen/sweet_seventeen.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/sweet_seventeen/sweet_seventeen.class
--------------------------------------------------------------------------------
/Add to Array-Form of Integer/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Add to Array-Form of Integer/Result.png
--------------------------------------------------------------------------------
/Candy in the box/Problem Statement.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Candy in the box/Problem Statement.docx
--------------------------------------------------------------------------------
/Median of Two Sorted Arrays/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Median of Two Sorted Arrays/Result.png
--------------------------------------------------------------------------------
/PalindromicString/ProblemStatement.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/PalindromicString/ProblemStatement.docx
--------------------------------------------------------------------------------
/Student Attendance Record I/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Student Attendance Record I/Result.png
--------------------------------------------------------------------------------
/geometric_series/geometric_series.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/geometric_series/geometric_series.class
--------------------------------------------------------------------------------
/Ali and Helping innocent people/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Ali and Helping innocent people/Result.png
--------------------------------------------------------------------------------
/Length of Last Word/Problem Statement.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Length of Last Word/Problem Statement.pdf
--------------------------------------------------------------------------------
/Search in Rotated Sorted Array/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Search in Rotated Sorted Array/Result.png
--------------------------------------------------------------------------------
/Sum of All Odd Length Subarrays/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Sum of All Odd Length Subarrays/Result.png
--------------------------------------------------------------------------------
/Remove Duplicates from Sorted List/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Remove Duplicates from Sorted List/Result.png
--------------------------------------------------------------------------------
/To Lower Case/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public String toLowerCase(String s) {
3 | return s.toLowerCase();
4 | }
5 | }
--------------------------------------------------------------------------------
/Categorize Box According to Criteria/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Categorize Box According to Criteria/Result.png
--------------------------------------------------------------------------------
/Pow(x,n)/Pow(x,n).java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public double myPow(double x, int n) {
3 | return Math.pow(x,n);
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/Remove Duplicates from Sorted Array/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Remove Duplicates from Sorted Array/Result.png
--------------------------------------------------------------------------------
/Roy and Profile Picture/Problem Statement.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Roy and Profile Picture/Problem Statement.docx
--------------------------------------------------------------------------------
/Median of Two Sorted Arrays/Problem Statement.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Median of Two Sorted Arrays/Problem Statement.docx
--------------------------------------------------------------------------------
/Remove Duplicates from Sorted List II/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Remove Duplicates from Sorted List II/Result.png
--------------------------------------------------------------------------------
/Student Attendance Record I/Problem Statement.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Student Attendance Record I/Problem Statement.docx
--------------------------------------------------------------------------------
/Plus One/Readme.md:
--------------------------------------------------------------------------------
1 | Output
2 | 
3 |
--------------------------------------------------------------------------------
/SortStringArrayCaseInSensitive/ProblemStatement.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/SortStringArrayCaseInSensitive/ProblemStatement.png
--------------------------------------------------------------------------------
/ Two Sum/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Ali and Helping innocent people/Problem Statement.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Ali and Helping innocent people/Problem Statement.pdf
--------------------------------------------------------------------------------
/Zoos/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Add Strings/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Divisibility/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Climbing Stairs/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Convert Binary Number in a Linked List to Integer/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ak2521/Java-Basic/HEAD/Convert Binary Number in a Linked List to Integer/Result.png
--------------------------------------------------------------------------------
/Find the Maximum Achievable Number/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int theMaximumAchievableX(int num, int t) {
3 | return num+(t*2);
4 | }
5 | }
--------------------------------------------------------------------------------
/Fizz Buzz/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Good Turn/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Happy Number/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Java Anagrams/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Java List/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Java Stack/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Single Number/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Sort Colors/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/SortStringArrayCaseInSensitive/readMe.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |
--------------------------------------------------------------------------------
/Split Strings/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Toggle String/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Ugly Number/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Valid Palindrome/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Water Bottles/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Who likes it?/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Contains Duplicate/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Day of the Year/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Highest and Lowest/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Linked List Cycle/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Maximum Subarray/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Missing Number/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Ones and Zeros/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Pass The Pillow/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Power of Four/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Power of Two/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Printer Errors/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Reverse Integer/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Roman to Integer/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/String ends with?/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Valid Boomerang/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Add to Array-Form of Integer/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Divide Two Integers/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Find The Parity Outlier/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Find the Difference/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Group Anagrams/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Power of Three/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Roy and Profile Picture/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Search Insert Position/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Sort Array By Parity/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Valid Perfect Square/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Factorial Trailing Zeroes/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Length of Last Word/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Middle of the Linked List/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/N-th Tribonacci Number/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Reverse Words in a String/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Student Attendance Record I/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Ali and Helping innocent people/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Search in Rotated Sorted Array/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Sum of All Odd Length Subarrays/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Tree Preorder Traversal/README.md:
--------------------------------------------------------------------------------
1 | # QUESTION & ANSWER
2 |
3 | 
4 |
5 |
--------------------------------------------------------------------------------
/Candy in the box/README.md:
--------------------------------------------------------------------------------
1 | #Test Case Only Passed
2 |
3 |
--------------------------------------------------------------------------------
/Remove Duplicates from Sorted Array/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Remove Duplicates from Sorted List II/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Remove Duplicates from Sorted List/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/PalindromicString/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Split houses/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Categorize Box According to Criteria/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Convert Binary Number in a Linked List to Integer/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Length of Last Word/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int lengthOfLastWord(String s) {
3 | String strarr[]=s.split(" ");
4 | return strarr[strarr.length-1].length();
5 | }
6 | }
--------------------------------------------------------------------------------
/Printer Errors/Kata.java:
--------------------------------------------------------------------------------
1 | public class Printer {
2 |
3 | public static String printerError(String s)
4 | {
5 | return s.replaceAll("[a-m]", "").length() + "/" + s.length();
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Java Regular expression/code.java:
--------------------------------------------------------------------------------
1 | class UsernameValidator {
2 | /*
3 | * Write regular expression here.
4 | */
5 | public static final String regularExpression = "[A-Za-z][A-Za-z0-9_]{7,29}";
6 | }
--------------------------------------------------------------------------------
/Median of Two Sorted Arrays/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Convert the Temperature/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public double[] convertTemperature(double celsius) {
3 | double []res=new double[2];
4 | res[0]=celsius+273.15;
5 | res[1]=celsius*1.8+32;
6 | return res;
7 | }
8 | }
--------------------------------------------------------------------------------
/Factorial Trailing Zeroes/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 |
3 | public int trailingZeroes(int n) {
4 | int res = 0;
5 | for(int i=5;i<=n;i=i*5){
6 | res = res + (n/i);
7 | }
8 | return res;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Smallest Even Multiple/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int smallestEvenMultiple(int n) {
3 | if(n%2==0)
4 | {
5 | return n;
6 | }
7 | else
8 | {
9 | return n*2;
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/Rotate Image/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 | Output:-
6 |
7 | 
8 |
--------------------------------------------------------------------------------
/Student Attendance Record I/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public boolean checkRecord(String s) {
3 | if(s.contains("LLL")||s.chars().filter(ch -> ch == 'A').count()>=2)
4 | {
5 | return false;
6 | }
7 | return true;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Jewels and Stones/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Shuffle String/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Sum Multiples/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/To Lower Case/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Truncate Sentence/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 | Output:-
6 |
7 | 
8 |
--------------------------------------------------------------------------------
/Ugly Number/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public boolean isUgly(int n) {
3 | if(n==0) return false;
4 | for(int i=2;i<=5;i+=i-1){
5 | while(n%i==0){
6 | n=n/i;
7 | }
8 | }
9 | return n==1;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Defanging an IP Address/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Merge Sorted Array/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Result:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Number of Good Pairs/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Pow(x,n)/README.md:
--------------------------------------------------------------------------------
1 | # Problem
2 |
3 | 
4 |
5 |
6 | # Result
7 |
8 | 
9 |
10 |
--------------------------------------------------------------------------------
/Search a 2D Matrix/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Result:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Set Matrix Zeroes/README.md:
--------------------------------------------------------------------------------
1 | # QUESTION:
2 |
3 | 
4 |
5 |
6 | # SOLUTION
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Sorting the Sentence/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Valid Parantheses/README.md:
--------------------------------------------------------------------------------
1 | # Question
2 |
3 | 
4 |
5 |
6 | # Solution
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Convert the Temperature/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Encode and Decode TinyURL/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Goal Parser Interpretation/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Smallest Even Multiple/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Cells with Odd Values in a Matrix/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/A Number After a Double Reversal/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Result:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Cells in a Range on an Excel Sheet/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Find the Maximum Achievable Number/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Account Balance After Rounded Purchase/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Result:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Check if a String Is an Acronym of Words/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Check if a String Is an Acronym of Words/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public boolean isAcronym(List words, String s) {
3 | String che="";
4 | for(String str:words)
5 | {
6 | che+=str.charAt(0);
7 | }
8 | return s.equals(che);
9 | }
10 | }
--------------------------------------------------------------------------------
/Maximum Number of Words Found in Sentences/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Missing Number/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Pointers in C/README.md:
--------------------------------------------------------------------------------
1 | # C pointer
2 |
3 | 
4 |
5 |
6 | # Result
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Check If Two String Arrays are Equivalent/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Divisible and Non-divisible Sums Difference/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Find the K-Beauty of a Number/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 |
4 | 
5 |
6 |
7 | Result:-
8 |
9 | 
10 |
--------------------------------------------------------------------------------
/Replace Elements with Greatest Element on Right Side/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Climbing Stairs/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int climbStairs(int n) {
3 | int[] ways = new int[n + 1];
4 | ways[0] = 1;
5 | ways[1] = 1;
6 | for (int i = 2; i <= n; i++) {
7 | ways[i] = ways[i - 1] + ways[i - 2];
8 | }
9 | return ways[n];
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Add Strings/Solution.java:
--------------------------------------------------------------------------------
1 | import java.lang.*;
2 | import java.math.BigInteger;
3 | import java.util.*;
4 | class Solution {
5 | public String addStrings(String num1, String num2) {
6 | BigInteger x = new BigInteger(num1);
7 | BigInteger y = new BigInteger(num2);
8 | return String.valueOf(x.add(y));
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Final Value of Variable After Performing Operations/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 |
7 | Output:-
8 |
9 | 
10 |
--------------------------------------------------------------------------------
/Find First and Last Position of Element in Sorted Array/README.md:
--------------------------------------------------------------------------------
1 | # Problem Statement
2 |
3 | 
4 |
5 |
6 | # Solution
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/Number of Steps to Reduce a Number to Zero/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 |
4 | 
5 |
6 |
7 | Output:-
8 |
9 |
10 | 
11 |
--------------------------------------------------------------------------------
/Truncate Sentence/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public String truncateSentence(String s, int k) {
3 | String []arr=s.split(" ");
4 | String res="";
5 | for(int i=0;i ['ab', 'c_']
6 | * 'abcdef' => ['ab', 'cd', 'ef']
7 |
--------------------------------------------------------------------------------
/Subtract the Product and Sum of Digits of an Integer/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 |
9 | 
10 |
--------------------------------------------------------------------------------
/Difference Between Element Sum and Digit Sum of an Array/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 |
3 | 
4 |
5 |
6 | Output:-
7 |
8 | 
9 |
10 |
--------------------------------------------------------------------------------
/Flipping an Image/Readme.md:
--------------------------------------------------------------------------------
1 | Question:-
2 | 
3 |
4 |
5 | Output:
6 |
7 | 
8 |
--------------------------------------------------------------------------------
/Array Reversal/README.md:
--------------------------------------------------------------------------------
1 | # Array Reversal problem statement
2 |
3 | 
4 |
5 |
6 | # Result
7 |
8 | 
9 |
10 |
--------------------------------------------------------------------------------
/Pointers in C/Pointers in C.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | void update(int *a,int *b) {
4 | *a=*a+*b;
5 | *b=abs(*a-*b-*b);
6 | }
7 |
8 | int main() {
9 | int a, b;
10 | int *pa = &a, *pb = &b;
11 |
12 | scanf("%d %d", &a, &b);
13 | update(pa, pb);
14 | printf("%d\n%d", a, b);
15 |
16 | return 0;
17 | }
--------------------------------------------------------------------------------
/Remove Duplicates from Sorted Array/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int removeDuplicates(int[] nums) {
3 | int c=0;
4 | for(int i=0;i=0 ; i--)
5 | {
6 | if(s.charAt(i)!= ' ')
7 | length++;
8 | else
9 | if(length>0) return length;
10 | }
11 | return length;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Power of Two/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public boolean isPowerOfTwo(int n) {
3 | if(n<1)
4 | {
5 | return false;
6 | }
7 | else if(n==1)
8 | {
9 | return true;
10 | }
11 | else if(n%2!=0)
12 | {
13 | return false;
14 | }
15 | return isPowerOfTwo(n/2);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Missing Number/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int missingNumber(int[] nums) {
3 | int len=nums.length;
4 | Arrays.sort(nums);
5 | int i=0;
6 | for(i=0;i binary) {
6 | String str="";
7 | for(int i:binary)
8 | {
9 | str=str+String.valueOf(i);
10 | }
11 | int decimal=Integer.parseInt(str,2);
12 | return decimal;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Water Bottles/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int numWaterBottles(int numBottles, int numExchange) {
3 | int sum=numBottles;
4 | while(numBottles>=numExchange)
5 | {
6 | int t=(numBottles/numExchange);
7 | sum=sum+t;
8 | numBottles=t+(numBottles%numExchange);
9 | }
10 | return sum;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Maximum Number of Words Found in Sentences/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int mostWordsFound(String[] sentences) {
3 | int max=0;
4 | for(int i=0;inums[i+1])
6 | {
7 | int temp=nums[i];
8 | nums[i]=nums[i+1];
9 | nums[i+1]=temp;
10 | i=-1;
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/Power of Four/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public boolean isPowerOfFour(int n) {
3 | if(n<1)
4 | {
5 | return false;
6 | }
7 | else if(n==1)
8 | {
9 | return true;
10 | }
11 | else if(n%4!=0)
12 | {
13 | return false;
14 | }
15 | return isPowerOfFour(n/4);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Power of Three/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public boolean isPowerOfThree(int n) {
3 | if(n<1)
4 | {
5 | return false;
6 | }
7 | else if(n==1)
8 | {
9 | return true;
10 | }
11 | else if(n%3!=0)
12 | {
13 | return false;
14 | }
15 | return isPowerOfThree(n/3);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Divide Two Integers/Solution.java:
--------------------------------------------------------------------------------
1 | import java.lang.Math;
2 | class Solution {
3 | public int divide(int di, int dr) {
4 | int x=di/dr;
5 | if (di == -2147483648 && dr == -1)
6 | {
7 | return (2147483647);
8 | }
9 | else if(di<0 && dr<0)
10 | {
11 | return Math.abs(x);
12 | }
13 |
14 | return x;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/oddlyeven/TCS Coding Question - 2.txt:
--------------------------------------------------------------------------------
1 | TCS Coding Question - 2
2 |
3 | Oddly Even:
4 | Given a maximum of 100 digit numbers as input, find the difference between the sum of odd and even position digits.
5 |
6 | Case 1:
7 | Input: 4567
8 | Expected Output: 2
9 | Explantion : Odd positions are 4 and 6 as they are pos: 1 and pos: 3, both have sum 10. Similarly, 5 and 7 are at even positions pos: 2 and pos: 4 with sum 12. Thus, difference is 12 - 10 = 2
--------------------------------------------------------------------------------
/Integer to Roman/Readme.md:
--------------------------------------------------------------------------------
1 | Question:
2 | 
3 | 
4 |
5 |
6 |
7 | Output:-
8 |
9 | 
10 |
--------------------------------------------------------------------------------
/Divisible and Non-divisible Sums Difference/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int differenceOfSums(int n, int m) {
3 | int sum1=0,sum2=0;
4 | for(int i=1;i<=n;i++)
5 | {
6 | if(i%m==0)
7 | {
8 | sum1+=i;
9 | }
10 | else
11 | {
12 | sum2+=i;
13 | }
14 | }
15 | return sum2-sum1;
16 | }
17 | }
--------------------------------------------------------------------------------
/Number of Good Pairs/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int numIdenticalPairs(int[] nums) {
3 | int count=0;
4 | for(int i=0;i
2 | #include
3 |
4 | int main()
5 | {
6 | int num, *arr, i;
7 | scanf("%d", &num);
8 | arr = (int*) malloc(num * sizeof(int));
9 | for(i = 0; i < num; i++) {
10 | scanf("%d", arr + i);
11 | }
12 |
13 |
14 | /* Write the logic to reverse the array. */
15 |
16 | for(i = num-1; i >= 0; i--)
17 | printf("%d ", *(arr + i));
18 | return 0;
19 | }
20 |
--------------------------------------------------------------------------------
/Defanging an IP Address/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public String defangIPaddr(String address) {
3 | String res="";
4 | for(int i=0;i= sum){
8 | sum = 0;
9 | }
10 | sum += nums[j];
11 | maxi = Math.max(maxi , sum);
12 | j++;
13 | }
14 | return maxi;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Jewels and Stones/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int numJewelsInStones(String jewels, String stones) {
3 | int c=0;
4 | for(int i=0;i=1 && n<=2)
9 | {
10 | return 1;
11 | }
12 | for(int i=2;i
12 |
13 |
--------------------------------------------------------------------------------
/Single Number/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int singleNumber(int[] nums) {
3 | Listys=new ArrayList();
4 | for(int i=0;i=0;j--,l++)
9 | {
10 | res[k][l]=matrix[j][i];
11 | }
12 | }
13 | for(int i=0;i0;i--)
13 | {
14 | if(i*i==num)
15 | {
16 | return true;
17 | }
18 | }
19 | return false;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Encode and Decode TinyURL/code.java:
--------------------------------------------------------------------------------
1 | public class Codec {
2 |
3 | // Encodes a URL to a shortened URL.
4 | public String encode(String longUrl) {
5 | return longUrl;
6 | }
7 |
8 | // Decodes a shortened URL to its original URL.
9 | public String decode(String shortUrl) {
10 | return shortUrl;
11 | }
12 | }
13 |
14 | // Your Codec object will be instantiated and called as such:
15 | // Codec codec = new Codec();
16 | // codec.decode(codec.encode(url));
--------------------------------------------------------------------------------
/Factorial Trailing Zeroes/ProblemStatement.txt:
--------------------------------------------------------------------------------
1 | Given an integer n, return the number of trailing zeroes in n!.
2 |
3 | Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1.
4 |
5 |
6 |
7 | Example 1:
8 |
9 | Input: n = 3
10 | Output: 0
11 | Explanation: 3! = 6, no trailing zero.
12 | Example 2:
13 |
14 | Input: n = 5
15 | Output: 1
16 | Explanation: 5! = 120, one trailing zero.
17 | Example 3:
18 |
19 | Input: n = 0
20 | Output: 0
21 |
22 |
23 | Constraints:
24 |
25 | 0 <= n <= 104
26 |
27 |
--------------------------------------------------------------------------------
/Group Anagrams/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public List> groupAnagrams(String[] strs) {
3 | Map> map = new HashMap<>();
4 | for (String str : strs) {
5 | char[] chars = str.toCharArray();
6 | Arrays.sort(chars);
7 | String key = String.valueOf(chars);
8 | map.computeIfAbsent(key, k -> new ArrayList<>()).add(str);
9 | }
10 | return new ArrayList<>(map.values());
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/sweet_seventeen/TCS Coding Question - 5.txt:
--------------------------------------------------------------------------------
1 | TCS Coding Question - 5
2 |
3 | SWEET SEVENTEEN:Given a maximum of four digit to the base 17 (10 - A, 11 - B, 12 - C, 13 - D .... 16 - G} as input, output its decimal value.
4 | Case 1:
5 | Input - 1A
6 | Expected Output - 27
7 |
8 | Explantion : The value A will be multiplied by 17^0 and value 1 will be multiplied by 17^1.
9 | => ((1*17^1) + (A*17^0))
10 | => ((1*17^1) + (10*17^0)) //As A equals 10
11 | => 17 + 10 => 27
12 | So the output will be 27
--------------------------------------------------------------------------------
/Power of Two/ProblemStatement.txt:
--------------------------------------------------------------------------------
1 | Given an integer n, return true if it is a power of two. Otherwise, return false.
2 |
3 | An integer n is a power of two, if there exists an integer x such that n == 2x.
4 |
5 |
6 |
7 | Example 1:
8 |
9 | Input: n = 1
10 | Output: true
11 | Explanation: 20 = 1
12 | Example 2:
13 |
14 | Input: n = 16
15 | Output: true
16 | Explanation: 24 = 16
17 | Example 3:
18 |
19 | Input: n = 3
20 | Output: false
21 |
22 |
23 | Constraints:
24 |
25 | -231 <= n <= 231 - 1
26 |
27 |
--------------------------------------------------------------------------------
/Java varargs simple addition/code.java:
--------------------------------------------------------------------------------
1 | class Add
2 | {
3 | void add(int... a)
4 | {
5 | int sum=0;
6 | for(int i:a)
7 | {
8 | sum+=i;
9 | }
10 | String str="";
11 | for(int i:a)
12 | {
13 | str+=Integer.toString(i)+"+";
14 | }
15 | String strres=str.substring(0,str.length()-1);
16 | strres+="="+Integer.toString(sum);
17 | System.out.println(strres);
18 | }
19 | }
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Power of Three/ProblemStatement.txt:
--------------------------------------------------------------------------------
1 | Given an integer n, return true if it is a power of three. Otherwise, return false.
2 |
3 | An integer n is a power of three, if there exists an integer x such that n == 3x.
4 |
5 |
6 |
7 | Example 1:
8 |
9 | Input: n = 27
10 | Output: true
11 | Explanation: 27 = 33
12 | Example 2:
13 |
14 | Input: n = 0
15 | Output: false
16 | Explanation: There is no x where 3x = 0.
17 | Example 3:
18 |
19 | Input: n = -1
20 | Output: false
21 | Explanation: There is no x where 3x = (-1).
22 |
--------------------------------------------------------------------------------
/ Two Sum/Solution.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 | class Solution {
3 | public int[] twoSum(int[] nums, int target) {
4 | int sum=0;
5 | int len=nums.length;
6 | for(int i=0;i= 0.
4 |
5 | Given n, return the value of Tn.
6 |
7 |
8 |
9 | Example 1:
10 |
11 | Input: n = 4
12 | Output: 4
13 | Explanation:
14 | T_3 = 0 + 1 + 1 = 2
15 | T_4 = 1 + 1 + 2 = 4
16 | Example 2:
17 |
18 | Input: n = 25
19 | Output: 1389537
20 |
21 |
22 | Constraints:
23 |
24 | 0 <= n <= 37
25 | The answer is guaranteed to fit within a 32-bit integer, ie. answer <= 2^31 - 1.
26 |
--------------------------------------------------------------------------------
/prime_number/problem_statement.txt:
--------------------------------------------------------------------------------
1 | TCS Coding Question - 4
2 |
3 | Prime Number: Write a code to check whether no is prime or not. Condition use function check() to find whether entered no is positive or negative ,if negative then enter the no, And if yes pas no as a parameter to prime() and check whether no is prime or not?
4 |
5 | Explantion : A number that is divisible by only and only 1 and itself is known as a Prime Number.
6 | For example: 11 is only divisible by 1, so 11 is prime, while 10 is divisible by 1, 2, and 5 so 10 is not a prime number.
--------------------------------------------------------------------------------
/Account Balance After Rounded Purchase/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int accountBalanceAfterPurchase(int purchaseAmount) {
3 | if(purchaseAmount==100)
4 | {
5 | return 0;
6 | }
7 | if(purchaseAmount%10==0)
8 | {
9 | return 100-purchaseAmount;
10 | }
11 | int round;
12 | round=(purchaseAmount/10)*10;
13 | if(purchaseAmount%10>=5)
14 | {
15 | round+=10;
16 | }
17 | return 100-round;
18 | }
19 | }
--------------------------------------------------------------------------------
/Reverse Integer/Question.txt:
--------------------------------------------------------------------------------
1 | Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.
2 |
3 | Assume the environment does not allow you to store 64-bit integers (signed or unsigned).
4 |
5 |
6 |
7 | Example 1:
8 |
9 | Input: x = 123
10 | Output: 321
11 | Example 2:
12 |
13 | Input: x = -123
14 | Output: -321
15 | Example 3:
16 |
17 | Input: x = 120
18 | Output: 21
19 |
20 |
21 | Constraints:
22 |
23 | -231 <= x <= 231 - 1
24 |
--------------------------------------------------------------------------------
/A Number After a Double Reversal/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public boolean isSameAfterReversals(int num) {
3 | StringBuilder in=new StringBuilder(Integer.toString(num));
4 | int rev1=Integer.parseInt(in.reverse().toString());
5 | in=new StringBuilder(Integer.toString(rev1));
6 | int rev2=Integer.parseInt(in.reverse().toString());
7 | if(rev2==num)
8 | {
9 | return true;
10 | }
11 | else
12 | {
13 | return false;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Highest and Lowest/ProblemStatement.txt:
--------------------------------------------------------------------------------
1 | In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number.
2 |
3 | Examples
4 |
5 | highAndLow("1 2 3 4 5") // return "5 1"
6 | highAndLow("1 2 -3 4 5") // return "5 -3"
7 | highAndLow("1 9 3 4 -5") // return "9 -5"
8 | Notes
9 |
10 | All numbers are valid Int32, no need to validate them.
11 | There will always be at least one number in the input string.
12 | Output string must be two numbers separated by a single space, and highest number is first
13 |
--------------------------------------------------------------------------------
/Search in Rotated Sorted Array/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int search(int[] nums, int target) {
3 | int result=-1;
4 | int len=nums.length;
5 | for(int i=0;i 1
8 | Testing: [0, 0, 1, 0] ==> 2
9 | Testing: [0, 1, 0, 1] ==> 5
10 | Testing: [1, 0, 0, 1] ==> 9
11 | Testing: [0, 0, 1, 0] ==> 2
12 | Testing: [0, 1, 1, 0] ==> 6
13 | Testing: [1, 1, 1, 1] ==> 15
14 | Testing: [1, 0, 1, 1] ==> 11
15 | However, the arrays can have varying lengths, not just limited to 4.
16 |
17 |
--------------------------------------------------------------------------------
/Split houses/Split_houses.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main()
3 | {
4 | int n,flag=0;
5 | scanf("%d",&n);
6 | char c[n];
7 | scanf("%s",c);
8 | for(int i=0;i set=new HashSet();
6 | while(n!=0 && !set.contains(n))
7 | {
8 | set.add(n);
9 | n=reduceFurther(n);
10 | }
11 | return n==1;
12 | }
13 | public int reduceFurther(int n)
14 | {
15 | int sum=0;
16 | while(n>0)
17 | {
18 | int remainder=n%10;
19 | sum=sum+(remainder*remainder);
20 | n=n/10;
21 | }
22 | return sum;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Remove Duplicates from Sorted List II/Question.txt:
--------------------------------------------------------------------------------
1 | Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as well.
2 |
3 |
4 |
5 | Example 1:
6 |
7 |
8 | Input: head = [1,2,3,3,4,4,5]
9 | Output: [1,2,5]
10 | Example 2:
11 |
12 |
13 | Input: head = [1,1,1,2,3]
14 | Output: [2,3]
15 |
16 |
17 | Constraints:
18 |
19 | The number of nodes in the list is in the range [0, 300].
20 | -100 <= Node.val <= 100
21 | The list is guaranteed to be sorted in ascending order.
22 |
--------------------------------------------------------------------------------
/Zoos/Zoos.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main(){
4 | char str[19];
5 | scanf("%s",str);
6 | int count=0,count1=0;
7 | int i;
8 | for(i=0;i methodList = new ArrayList<>();
8 | for(Method m:methods){
9 | methodList.add(m.getName());
10 | }
11 | Collections.sort(methodList);
12 | for(String name: methodList){
13 | System.out.println(name);
14 | }
15 | }
16 |
17 | }
--------------------------------------------------------------------------------
/Replace Elements with Greatest Element on Right Side/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int[] replaceElements(int[] arr) {
3 | int []arr1=new int[arr.length];
4 | int max;
5 | for(int i=0;imax)
11 | {
12 | max=arr[j];
13 | }
14 | }
15 | arr[i]=max;
16 | }
17 | arr[arr.length-1]=-1;
18 | return arr;
19 | }
20 | }
--------------------------------------------------------------------------------
/Valid Boomerang/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public boolean isBoomerang(int[][] points) {
3 | int x1 = points[0][0];
4 | int y1 = points[0][1];
5 | int x2 = points[1][0];
6 | int y2 = points[1][1];
7 | int x3 = points[2][0];
8 | int y3 = points[2][1];
9 | if ((x1 == x2 && y1 == y2) || (x2 == x3 && y2 == y3) || (x1 == x3 && y1 == y3)) {
10 | return false;
11 | }
12 | else if((y2-y1)*(x3-x2)==(x2-x1)*(y3-y2))
13 | {
14 | return false;
15 | }
16 | return true;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Climbing Stairs/Question.txt:
--------------------------------------------------------------------------------
1 | You are climbing a staircase. It takes n steps to reach the top.
2 |
3 | Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
4 |
5 |
6 |
7 | Example 1:
8 |
9 | Input: n = 2
10 | Output: 2
11 | Explanation: There are two ways to climb to the top.
12 | 1. 1 step + 1 step
13 | 2. 2 steps
14 | Example 2:
15 |
16 | Input: n = 3
17 | Output: 3
18 | Explanation: There are three ways to climb to the top.
19 | 1. 1 step + 1 step + 1 step
20 | 2. 1 step + 2 steps
21 | 3. 2 steps + 1 step
22 |
23 |
24 | Constraints:
25 |
26 | 1 <= n <= 45
27 |
--------------------------------------------------------------------------------
/Elements within Ranges/README.md:
--------------------------------------------------------------------------------
1 | # Elements within Ranges
2 |
3 | The motive of the problem is to find the number of elements in the array within the given ranges(inclusive of both ends of range).
4 |
5 | ## Sample Input
6 |
7 | - The 1st line has number of elements in array and number of ranges.
8 | - The 2nd line has the elements of the array.
9 | - The next following lines has the ranges as specified in the first line.
10 |
11 | ```
12 | 10 2
13 | 0 1 2 3 4 5 6 7 8 9
14 | 1 4
15 | 6 8
16 | ```
17 |
18 | ## Output
19 |
20 | The output of the above sample input will be,
21 |
22 | ```
23 | 4 3
24 | ```
25 |
--------------------------------------------------------------------------------
/Fizz Buzz/Question.txt:
--------------------------------------------------------------------------------
1 | Given an integer n, return a string array answer (1-indexed) where:
2 |
3 | answer[i] == "FizzBuzz" if i is divisible by 3 and 5.
4 | answer[i] == "Fizz" if i is divisible by 3.
5 | answer[i] == "Buzz" if i is divisible by 5.
6 | answer[i] == i (as a string) if none of the above conditions are true.
7 |
8 |
9 | Example 1:
10 |
11 | Input: n = 3
12 | Output: ["1","2","Fizz"]
13 | Example 2:
14 |
15 | Input: n = 5
16 | Output: ["1","2","Fizz","4","Buzz"]
17 | Example 3:
18 |
19 | Input: n = 15
20 | Output: ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
21 |
--------------------------------------------------------------------------------
/Valid Braces/README.md:
--------------------------------------------------------------------------------
1 | #Without Stack
2 | public class BraceChecker {
3 |
4 | public boolean isValid(String braces) {
5 | String b = braces;
6 | System.out.println(braces);
7 | for(int i=0;i
20 |
--------------------------------------------------------------------------------
/Shuffle String/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public String restoreString(String s, int[] indices) {
3 | String res="";
4 | for(int i=0;i=0 && arr[j]>key)
12 | {
13 | arr[j+1]=arr[j];
14 | j--;
15 | }
16 | arr[j+1]=key;
17 | }
18 | System.out.println(Arrays.toString(arr));
19 | }
20 | public static void main(String args[])
21 | {
22 | sort(new int[] {4,3,2,10,12,1,5,6});
23 | }
24 | }
--------------------------------------------------------------------------------
/Single Number/Question.txt:
--------------------------------------------------------------------------------
1 | Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.
2 |
3 | You must implement a solution with a linear runtime complexity and use only constant extra space.
4 |
5 |
6 |
7 | Example 1:
8 |
9 | Input: nums = [2,2,1]
10 | Output: 1
11 | Example 2:
12 |
13 | Input: nums = [4,1,2,1,2]
14 | Output: 4
15 | Example 3:
16 |
17 | Input: nums = [1]
18 | Output: 1
19 |
20 |
21 | Constraints:
22 |
23 | 1 <= nums.length <= 3 * 104
24 | -3 * 104 <= nums[i] <= 3 * 104
25 | Each element in the array appears twice except for one element which appears only once.
26 |
--------------------------------------------------------------------------------
/Middle of the Linked List/Question.txt:
--------------------------------------------------------------------------------
1 | Given the head of a singly linked list, return the middle node of the linked list.
2 |
3 | If there are two middle nodes, return the second middle node.
4 |
5 |
6 |
7 | Example 1:
8 |
9 |
10 | Input: head = [1,2,3,4,5]
11 | Output: [3,4,5]
12 | Explanation: The middle node of the list is node 3.
13 | Example 2:
14 |
15 |
16 | Input: head = [1,2,3,4,5,6]
17 | Output: [4,5,6]
18 | Explanation: Since the list has two middle nodes with values 3 and 4, we return the second one.
19 |
20 |
21 | Constraints:
22 |
23 | The number of nodes in the list is in the range [1, 100].
24 | 1 <= Node.val <= 100
25 |
--------------------------------------------------------------------------------
/Toggle String/TestClass.java:
--------------------------------------------------------------------------------
1 |
2 | import java.util.*;
3 | class TestClass {
4 | public static void main(String args[] ) throws Exception {
5 | Scanner sc=new Scanner(System.in);
6 | String input=sc.next();
7 | String out="";
8 | char[] ip=input.toCharArray();
9 | for(int i=0;i=97 && x<=122)
13 | { x=x-32;
14 | out=out+(char)x;
15 | }
16 | else
17 | {
18 | x=x+32;
19 | out=out+(char)x;
20 | }
21 | }
22 | System.out.println(out);
23 | }
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/Good Turn/Codechef.java:
--------------------------------------------------------------------------------
1 | /* package codechef; // don't place package name! */
2 |
3 | import java.util.*;
4 | import java.lang.*;
5 | import java.io.*;
6 |
7 | /* Name of the class has to be "Main" only if the class is public. */
8 | class Codechef
9 | {
10 | public static void main (String[] args) throws java.lang.Exception
11 | {
12 | // your code goes here
13 | Scanner sc =new Scanner(System.in);
14 | int t=sc.nextInt();
15 | for(int i=0;i6 ?"YES":"NO";
20 | System.out.println(res);
21 | }
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/Middle of the Linked List/Solution.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Definition for singly-linked list.
3 | * public class ListNode {
4 | * int val;
5 | * ListNode next;
6 | * ListNode() {}
7 | * ListNode(int val) { this.val = val; }
8 | * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
9 | * }
10 | */
11 | class Solution {
12 | public ListNode middleNode(ListNode head) {
13 | ListNode slow=head;
14 | ListNode fast=head;
15 | while(fast!=null && fast.next!=null){
16 | slow = slow.next;
17 | fast = fast.next.next;
18 | }
19 | return slow;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Sum of All Odd Length Subarrays/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int sumOddLengthSubarrays(int[] arr) {
3 | int result = 0;
4 | int n = arr.length;
5 |
6 | for (int i = 0; i < n; i++) {
7 | int endingHere = i + 1;
8 | int startingHere = n - i;
9 | int totalSubarrays = endingHere * startingHere;
10 | int oddSubarrays = totalSubarrays / 2;
11 | if (totalSubarrays % 2 == 1) {
12 | oddSubarrays++;
13 | }
14 | result += oddSubarrays * arr[i];
15 | }
16 |
17 | return result;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/String ends with?/ProblemStatement.txt:
--------------------------------------------------------------------------------
1 | import java.lang.*;
2 | public class Kata {
3 | public static boolean solution(String str, String ending) {
4 | int count=0;
5 | int strlen=str.length();
6 | int endinglen=ending.length();
7 | int start=Math.abs(strlen-endinglen);
8 | String strending=str.substring(start,strlen);
9 | if(strending.equals(ending))
10 | {
11 | return true;
12 | }
13 | return false;
14 | }
15 | }
16 |
17 | //else use this peice of code
18 |
19 | /*public class Kata {
20 | public static boolean solution(String str, String ending) {
21 | return str.endsWith(ending);
22 | }
23 | }*/
24 |
--------------------------------------------------------------------------------
/Add to Array-Form of Integer/Question.txt:
--------------------------------------------------------------------------------
1 | The array-form of an integer num is an array representing its digits in left to right order.
2 |
3 | For example, for num = 1321, the array form is [1,3,2,1].
4 | Given num, the array-form of an integer, and an integer k, return the array-form of the integer num + k.
5 |
6 |
7 |
8 | Example 1:
9 |
10 | Input: num = [1,2,0,0], k = 34
11 | Output: [1,2,3,4]
12 | Explanation: 1200 + 34 = 1234
13 | Example 2:
14 |
15 | Input: num = [2,7,4], k = 181
16 | Output: [4,5,5]
17 | Explanation: 274 + 181 = 455
18 | Example 3:
19 |
20 | Input: num = [2,1,5], k = 806
21 | Output: [1,0,2,1]
22 | Explanation: 215 + 806 = 1021
23 |
24 |
--------------------------------------------------------------------------------
/Find the Difference/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public char findTheDifference(String s, String t) {
3 | if(t.length()>s.length())
4 | {
5 | s=s+" ";
6 | }
7 | char result='r';
8 | char[] x=s.toCharArray();
9 | char[] y=t.toCharArray();
10 | Arrays.sort(x);
11 | Arrays.sort(y);
12 | for(int i=0;i0)
26 | {
27 | System.out.println(check(input));
28 | }
29 | else{
30 | System.out.println("Negative number :(");
31 | }
32 |
33 | }
34 | }
--------------------------------------------------------------------------------
/Fizz Buzz/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public List fizzBuzz(int n) {
3 | Listlt=new ArrayList();
4 | for(int i=1;i<=n;i++)
5 | {
6 | if(i%3==0 && i%5==0)
7 | {
8 | lt.add("FizzBuzz");
9 | }
10 | else if(i%3==0 && i%5!=0)
11 | {
12 | lt.add("Fizz");
13 | }
14 | else if(i%3!=0 && i%5==0)
15 | {
16 | lt.add("Buzz");
17 | }
18 | else
19 | {
20 | lt.add(String.valueOf(i));
21 | }
22 | }
23 | return lt;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Remove Duplicates from Sorted List/Solution.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Definition for singly-linked list.
3 | * public class ListNode {
4 | * int val;
5 | * ListNode next;
6 | * ListNode() {}
7 | * ListNode(int val) { this.val = val; }
8 | * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
9 | * }
10 | */
11 | class Solution {
12 | public ListNode deleteDuplicates(ListNode head) {
13 | ListNode temp=head;
14 | while (temp != null) {
15 | while(temp.next != null && temp.next.val == temp.val) {
16 | temp.next = temp.next.next;
17 | }
18 | temp = temp.next;
19 | }
20 | return head;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Valid Perfect Square/ProblemStatement.txt:
--------------------------------------------------------------------------------
1 | Given a positive integer num, return true if num is a perfect square or false otherwise.
2 |
3 | A perfect square is an integer that is the square of an integer. In other words, it is the product of some integer with itself.
4 |
5 | You must not use any built-in library function, such as sqrt.
6 |
7 |
8 |
9 | Example 1:
10 |
11 | Input: num = 16
12 | Output: true
13 | Explanation: We return true because 4 * 4 = 16 and 4 is an integer.
14 | Example 2:
15 |
16 | Input: num = 14
17 | Output: false
18 | Explanation: We return false because 3.742 * 3.742 = 14 and 3.742 is not an integer.
19 |
20 |
21 | Constraints:
22 |
23 | 1 <= num <= 231 - 1
24 |
--------------------------------------------------------------------------------
/Linked List Cycle/Solution.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Definition for singly-linked list.
3 | * class ListNode {
4 | * int val;
5 | * ListNode next;
6 | * ListNode(int x) {
7 | * val = x;
8 | * next = null;
9 | * }
10 | * }
11 | */
12 | public class Solution {
13 | public boolean hasCycle(ListNode head) {
14 | ListNode slow=head;
15 | ListNode fast=head;
16 | while(fast!=null && fast.next!=null)
17 | {
18 | slow=slow.next;
19 | fast=fast.next.next;
20 | if(slow==fast)
21 | {
22 | return true;
23 | }
24 | }
25 | return false;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/AddCharacter/Question.txt:
--------------------------------------------------------------------------------
1 | Input: a1b2c3
2 | Output: abbccc
3 |
4 | Caution: Don't use inbuilt functions
5 |
6 | Explanation:
7 | After we have the number 1 so a repeats one time = a
8 | After b we have the number 2 so it repeats two times = bb
9 | After c we have the number 3 so it repeats three times = ccc
10 | Final Output: abbccc
11 |
12 | Algorithm:
13 | 1.Start the Program
14 | 2.Get the input as a single string
15 | 3.Loop through the entire string to find the numbers
16 | 4.After finding the number, Repeat the previous character the same number of times
17 | 5.For example a4 ( So you find the number 4 and print a 4 times)
18 | 6.Follow step 3,4 for the entire string
19 | 7.End the Program
20 |
21 |
--------------------------------------------------------------------------------
/Java Anagrams/WithInbuild.java:
--------------------------------------------------------------------------------
1 | import java.io.*;
2 | import java.util.*;
3 | public class WithInbuild {
4 |
5 | public static void main(String[] args) {
6 | Scanner sc =new Scanner(System.in);
7 | String a=sc.next();
8 | String b=sc.next();
9 | a=a.toLowerCase();
10 | b=b.toLowerCase();
11 | char[] str1=a.toCharArray();
12 | char[] str2=b.toCharArray();
13 | Arrays.sort(str1);
14 | Arrays.sort(str2);
15 | if(String.valueOf(str1).equals(String.valueOf(str2)))
16 | {
17 | System.out.print("Anagrams");
18 | }
19 | else
20 | System.out.print("Not Anagrams");
21 | }
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/Group Anagrams/Question.txt:
--------------------------------------------------------------------------------
1 | Given an array of strings strs, group the anagrams together. You can return the answer in any order.
2 |
3 | An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
4 |
5 |
6 |
7 | Example 1:
8 |
9 | Input: strs = ["eat","tea","tan","ate","nat","bat"]
10 | Output: [["bat"],["nat","tan"],["ate","eat","tea"]]
11 | Example 2:
12 |
13 | Input: strs = [""]
14 | Output: [[""]]
15 | Example 3:
16 |
17 | Input: strs = ["a"]
18 | Output: [["a"]]
19 |
20 |
21 | Constraints:
22 |
23 | 1 <= strs.length <= 104
24 | 0 <= strs[i].length <= 100
25 | strs[i] consists of lowercase English letters.
26 |
--------------------------------------------------------------------------------
/Search a 2D Matrix/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public boolean searchMatrix(int[][] matrix, int target) {
3 | int m,n;
4 | m=matrix.length;
5 | n=matrix[0].length;
6 | for(int i=0;imatrix[i][n-1])
9 | {
10 | continue;
11 | }
12 | else
13 | {
14 | for(int j=0;jmax)
23 | {
24 | max=c2[i];
25 | max1=i+1;
26 |
27 | }
28 |
29 | }
30 |
31 | System.out.println(max1);
32 |
33 |
34 |
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/Valid Braces/ProblemStatement.txt:
--------------------------------------------------------------------------------
1 | Write a function that takes a string of braces, and determines if the order of the braces is valid. It should return true if the string is valid, and false if it's invalid.
2 |
3 | This Kata is similar to the Valid Parentheses Kata, but introduces new characters: brackets [], and curly braces {}. Thanks to @arnedag for the idea!
4 |
5 | All input strings will be nonempty, and will only consist of parentheses, brackets and curly braces: ()[]{}.
6 |
7 | What is considered Valid?
8 |
9 | A string of braces is considered valid if all braces are matched with the correct brace.
10 |
11 | Examples
12 |
13 | "(){}[]" => True
14 | "([{}])" => True
15 | "(}" => False
16 | "[(])" => False
17 | "[({})](]" => False
18 |
--------------------------------------------------------------------------------
/Sorting the Sentence/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public String sortSentence(String s) {
3 | String []arr=s.split(" ");
4 | for(int i=0;iarr[i+1].charAt(arr[i+1].length()-1))
7 | {
8 | String temp=arr[i];
9 | arr[i]=arr[i+1];
10 | arr[i+1]=temp;
11 | i=-1;
12 | }
13 | }
14 | String res="";
15 | for(int i=0;i addToArrayForm(int[] num, int k) {
5 | String str=Arrays.toString(num);
6 | str=str.replaceAll(",","");
7 | str=str.replaceAll(" ","");
8 | str=str.replace("[","");
9 | str=str.replace("]","");
10 | BigInteger num1=new BigInteger(str);
11 | BigInteger num2=new BigInteger(String.valueOf(k));
12 | str=String.valueOf(num1.add(num2));
13 | Listlt =new ArrayList();
14 | //System.out.println(str);
15 | for(int i=0;i2)
15 | {
16 | days=days+1;
17 | }
18 | for(int i=0;iodd=new ArrayList();
7 | Listeven=new ArrayList();
8 | for(int i:integers)
9 | {
10 | if(i%2==0)
11 | {
12 | even.add(i);
13 | }
14 | else
15 | {
16 | odd.add(i);
17 | }
18 | }
19 | return even.size()==1 ? even.get(0) :odd.get(0);
20 | }
21 | }
22 |
23 | //Implementation Using Streams
24 |
25 | /*import java.util.*;
26 | public class FindOutlier{
27 | static int find(int[] integers){
28 | int[] odd=Arrays.stream(integers).filter(c->c%2!=0).toArray();
29 | int[] even=Arrays.stream(integers).filter(c->c%2==0).toArray();
30 | return odd.length==1?odd[0]:even[0];
31 | }}*/
32 |
--------------------------------------------------------------------------------
/Difference Between Element Sum and Digit Sum of an Array/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int differenceOfSum(int[] nums) {
3 | String []strarr=new String[nums.length];
4 | for(int i=0;i0)?sum1-sum2:((sum1-sum2)*-1);
23 | return dif;
24 | }
25 | }
--------------------------------------------------------------------------------
/Who likes it?/ProblemStatement.txt:
--------------------------------------------------------------------------------
1 | DESCRIPTION:
2 |
3 | You probably know the "like" system from Facebook and other pages. People can "like" blog posts, pictures or other items. We want to create the text that should be displayed next to such an item.
4 |
5 | Implement the function which takes an array containing the names of people that like an item. It must return the display text as shown in the examples:
6 |
7 | [] --> "no one likes this"
8 | ["Peter"] --> "Peter likes this"
9 | ["Jacob", "Alex"] --> "Jacob and Alex like this"
10 | ["Max", "John", "Mark"] --> "Max, John and Mark like this"
11 | ["Alex", "Jacob", "Mark", "Max"] --> "Alex, Jacob and 2 others like this"
12 | Note: For 4 or more names, the number in "and 2 others" simply increases.
13 |
14 |
--------------------------------------------------------------------------------
/Good Turn/ProblemStatement.txt:
--------------------------------------------------------------------------------
1 | Chef and Chefina are playing with dice. In one turn, both of them roll their dice at once.
2 | They consider a turn to be good if the sum of the numbers on their dice is greater than 6.
3 | Given that in a particular turn Chef and Chefina got X and Y on their respective dice, find
4 | whether the turn was good.
5 |
6 | Input Format
7 | The first line of input will contain a single integer T
8 | T, denoting the number of test cases.
9 | Each test case contains two space-separated integers
10 | X and Y — the numbers Chef and Chefina got on their respective dice.
11 | Output Format
12 | For each test case, output on a new line, YES, if the turn was good and NO otherwise.
13 | Each character of the output may be printed in either uppercase or lowercase. That is, the strings NO, no, nO, and No will be treated as equivalent.
--------------------------------------------------------------------------------
/Is a number prime?/ProblemStatement.txt:
--------------------------------------------------------------------------------
1 | Define a function that takes an integer argument and returns a logical value true or false depending on if the integer is a prime.
2 |
3 | Per Wikipedia, a prime number ( or a prime ) is a natural number greater than 1 that has no positive divisors other than 1 and itself.
4 |
5 | Requirements
6 |
7 | You can assume you will be given an integer input.
8 | You can not assume that the integer will be only positive. You may be given negative numbers as well ( or 0 ).
9 | NOTE on performance: There are no fancy optimizations required, but still the most trivial solutions might time out. Numbers go up to 2^31 ( or similar, depending on language ). Looping all the way up to n, or n/2, will be too slow.
10 | Example
11 |
12 | is_prime(1) /* false */
13 | is_prime(2) /* true */
14 | is_prime(-1) /* false */
15 |
--------------------------------------------------------------------------------
/Find the K-Beauty of a Number/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int divisorSubstrings(int num, int k) {
3 | ArrayList arr=new ArrayList();
4 | String str=Integer.toString(num);
5 | if(str.length()==k)
6 | {
7 | return 1;
8 | }
9 | for(int i=0;i<=str.length()-k;i++)
10 | {
11 | arr.add(str.substring(i,i+k));
12 | }
13 | int count=0;
14 | System.out.println(arr);
15 | for(String i:arr)
16 | {
17 | int check=Integer.parseInt(i);
18 | if(check==0)
19 | {
20 | continue;
21 | }
22 | if(num%check==0)
23 | {
24 | count++;
25 | }
26 | }
27 | return count;
28 | }
29 | }
--------------------------------------------------------------------------------
/Missing Number/Question.txt:
--------------------------------------------------------------------------------
1 | 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.
2 |
3 |
4 |
5 | Example 1:
6 |
7 | Input: nums = [3,0,1]
8 | Output: 2
9 | 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.
10 | Example 2:
11 |
12 | Input: nums = [0,1]
13 | Output: 2
14 | Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums.
15 | Example 3:
16 |
17 | Input: nums = [9,6,4,2,3,5,7,0,1]
18 | Output: 8
19 | Explanation: n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums.
20 |
21 |
--------------------------------------------------------------------------------
/Sorting Algorithms/selectionSort.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | class selectionSort
3 | {
4 | public void sort(int arr[])
5 | {
6 | int size=arr.length;
7 | int min,i=0,j=0;
8 | for(i=0;iarr[j])
14 | {
15 | min=j;
16 | }
17 | }
18 | int temp=arr[min];
19 | arr[min]=arr[i];
20 | arr[i]=temp;
21 | }
22 | System.out.println(Arrays.toString(arr));
23 |
24 | }
25 | public static void main(String args[])
26 | {
27 | selectionSort s =new selectionSort();
28 | s.sort(new int[] {5,6,1,2,8,9,3,12,10,0,20,17,15,12,30,92,100,55,-1,6,-2});
29 | }
30 | }
--------------------------------------------------------------------------------
/Set Matrix Zeroes/Set Matrix Zeroes.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public void setZeroes(int[][] matrix) {
3 |
4 | int arr[][] = new int [matrix.length][matrix[0].length];
5 |
6 |
7 | for(int i=0;i=0;i--)
11 | {
12 | // Reversing The String name
13 | String ch=Character.toString(name.charAt(i));
14 | out=out+ch;
15 | }
16 | // Checking Input And Reversed String Are Same
17 | // If Same Print "YES"
18 | // Else Print "No"
19 | if(name.equals(out))
20 | {
21 | System.out.println("YES");
22 | }
23 | else
24 | {
25 | System.out.print("NO");
26 | }
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/Remove Duplicates from Sorted List II/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public ListNode deleteDuplicates(ListNode head) {
3 | if(head==null)
4 | {
5 | return head;
6 | }
7 |
8 | ListNode singleList =new ListNode();
9 | singleList.next=head;
10 | ListNode ptr=singleList;
11 | while(ptr.next!=null && ptr.next.next!=null)
12 | {
13 | if(ptr.next.val==ptr.next.next.val)
14 | {
15 | int value =ptr.next.val;
16 | while(ptr.next!=null && ptr.next.val==value)
17 | {
18 | ptr.next=ptr.next.next;
19 | }
20 | }
21 | else
22 | {
23 | ptr=ptr.next;
24 | }
25 | }
26 | return singleList.next;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Reverse Integer/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public String Rev(String s)
3 | {
4 | String op="";
5 | for(int i=s.length()-1;i>=0;i--)
6 | {
7 | op=op+s.charAt(i);
8 | }
9 | return op;
10 | }
11 | public int reverse(int x) {
12 | String str=String.valueOf(x);
13 | String out="";
14 | int result=0;
15 | try
16 | {
17 | if(str.charAt(0)=='-')
18 | {
19 | out=Rev(str.substring(1,str.length()));
20 | result=-1*(Integer.parseInt(out));
21 | }
22 | else
23 | {
24 | out=Rev((String)str);
25 | result=1*(Integer.parseInt(out));
26 | }
27 | }
28 | catch(Exception e)
29 | {
30 | return 0;
31 | }
32 | return result;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Java List/Solution.java:
--------------------------------------------------------------------------------
1 | import java.io.*;
2 | import java.util.*;
3 |
4 | public class Solution {
5 |
6 | public static void main(String[] args) {
7 | Scanner sc=new Scanner(System.in);
8 | Listlt=new ArrayList();
9 | int n=sc.nextInt();
10 | for(int i=0;ieven=new ArrayList();
12 | Listodd=new ArrayList();
13 | for(int i=0;i va_arg(p,int)) {
19 | min = va_arg(p,int);
20 | }
21 | }
22 | va_end(p);
23 | return min;
24 |
25 | }
26 |
27 | int max(int count,...) {
28 | int max = MAX_ELEMENT;
29 | va_list p;
30 | va_start(p,count);
31 | for(int i=0; inums[len-1])
29 | {
30 | return len;
31 | }
32 | find(nums,target,0,len/2);
33 | find(nums,target,len/2,len);
34 | return result==-1 ? res : result;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Valid Braces/Kata.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | public class BraceChecker {
3 |
4 | public boolean isValid(String s) {
5 | Stacklt =new Stack();
6 | for(int i=0;i lt=new ArrayList();
5 | numbers=numbers+" ";
6 | String str="";
7 | for(int i=0;i Value of R(row)
13 | 3 -> value of C(column)
14 | [0 1 0 1 1 0 1 1 1] -> Elements of the array M[R][C] where each element is separated by new line.
15 | Output :
16 | 3 -> Row 3 has maximum number of 1’s
17 |
18 | Example 2:
19 | input :
20 | 4 -> Value of R(row)
21 | 3 -> Value of C(column)
22 | [0 1 0 1 1 0 1 0 1 1 1 1] -> Elements of the array M[R][C]
23 | Output :
24 | 4 -> Row 4 has maximum number of 1’s
25 |
--------------------------------------------------------------------------------
/Categorize Box According to Criteria/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public String categorizeBox(int length, int width, int height, int mass) {
3 | double val = Math.pow(10, 4);
4 | String b="",h="";
5 | if(mass>=100)
6 | {
7 | h="Heavy";
8 | }
9 | if(length >= val || width >= val || height >= val )
10 | {
11 | b="Bulky";
12 | }
13 | else if((long)length*width*height >= Math.pow(10,9))
14 | {
15 | b="Bulky";
16 | }
17 | if(b.equals("Bulky") && h.equals("Heavy"))
18 | {
19 | return "Both";
20 | }
21 | else if(!b.equals("Bulky") && !h.equals("Heavy"))
22 | {
23 | return "Neither";
24 | }
25 | else if(b.equals("Bulky") && !h.equals("Heavy"))
26 | {
27 | return "Bulky";
28 | }
29 | else
30 | {
31 | return "Heavy";
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Sorting Algorithms/bubbleSort.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | class bubbleSort
3 | {
4 | static void sort(int[] arr)
5 | {
6 | int n=arr.length;
7 | boolean swapped=false;
8 | for(int i=0;iarr[j+1])
13 | {
14 | int temp=arr[j+1];
15 | arr[j+1]=arr[j];
16 | arr[j]=temp;
17 | swapped=true;
18 | }
19 | }
20 | if(i>=1 && swapped!=true)
21 | {
22 | System.out.println(Arrays.toString(arr)+" O(n)");
23 | System.exit(0);
24 | }
25 | }
26 | System.out.println(Arrays.toString(arr)+" O(n*n)");
27 | }
28 | public static void main(String args[])
29 | {
30 | sort(new int[] {13,32,26,35,10}); //avg case
31 | sort(new int[] {1,2,3,4,5}); //best case
32 | }
33 | }
--------------------------------------------------------------------------------
/Compare Banks/Solution.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 |
3 | public class Solution {
4 |
5 | public static void main(String[] args) {
6 | Scanner sc = new Scanner(System.in);
7 | int p = sc.nextInt();
8 | int t = sc.nextInt();
9 | int n1 = sc.nextInt();
10 | int m;
11 | float in;
12 | float tot = 0;
13 | // for bank 1
14 | for (int i = 0; i < n1; ++i) {
15 | m = sc.nextInt();
16 | in = sc.nextFloat();
17 | tot += p * (in / 1 - (1 / Math.pow((1 + in), m * 12))) * m;
18 | }
19 | int n2 = sc.nextInt();
20 | float tot2 = 0;
21 | // for bank 2
22 | for (int i = 0; i < n2; ++i) {
23 | m = sc.nextInt();
24 | in = sc.nextFloat();
25 | tot2 += p * (in / 1 - (1 / Math.pow((1 + in), t * 12))) * m;
26 | }
27 | if (tot2 <= tot)
28 | System.out.println("Bank B");
29 | else
30 | System.out.println("Bank A");
31 | sc.close();
32 | }
33 | }
--------------------------------------------------------------------------------
/Elements within Ranges/Solution.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 |
3 | public class Solution {
4 |
5 | public static void main(String[] args) {
6 | // Create scanner
7 | Scanner sc = new Scanner(System.in);
8 | int n = sc.nextInt();
9 | int r = sc.nextInt();
10 | int arr[] = new int[n];
11 | // get array
12 | for (int i = 0; i < n; ++i) {
13 | arr[i] = sc.nextInt();
14 | }
15 | // get ranges
16 | int ranges[][] = new int[r][2];
17 | for (int i = 0; i < r; ++i) {
18 | ranges[i][0] = sc.nextInt();
19 | ranges[i][1] = sc.nextInt();
20 | }
21 | int count = 0;
22 | // find count of elements within the range
23 | for (int i = 0; i < r; ++i, count = 0) {
24 | for (int j = 0; j < n; ++j) {
25 | if (arr[j] > ranges[i][0] && arr[j] < ranges[i][1])
26 | ++count;
27 | }
28 | System.out.print(count + " ");
29 | }
30 | sc.close();
31 | }
32 | }
--------------------------------------------------------------------------------
/Flipping an Image/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int[][] flipAndInvertImage(int[][] image) {
3 | int m=image.length,n=image[0].length;
4 | int [][]arr=new int[m][n];
5 | for(int i=0,k=0;i=0;j--,l++)
8 | {
9 | arr[k][l]=image[i][j];
10 | }
11 | }
12 | for(int i=0;i cellsInRange(String s) {
3 | String numb1="";
4 | numb1+=s.charAt(1);
5 | List res=new ArrayList();
6 | int n1=Integer.parseInt(numb1);
7 | String numb2="";
8 | numb2+=s.charAt(4);
9 | int n2=Integer.parseInt(numb2);
10 | int one=(int)s.charAt(0);
11 | int two=(int)s.charAt(3);
12 | //System.out.println("n1 "+n1+" n2 "+n2+" one "+one+" two "+two);
13 | for(int i=one;i<=two;i++)
14 | {
15 | char ch1=(char)i;
16 | //System.out.println(ch1);
17 | for(int j=n1;j<=n2;j++)
18 | {
19 | char ch2=(char)(j+'0');
20 | //System.out.println(ch2);
21 | String su="";
22 | su+=ch1;
23 | su+=ch2;
24 | //System.out.println(su);
25 | res.add(su);
26 | }
27 | }
28 | return res;
29 | }
30 | }
--------------------------------------------------------------------------------
/Sorting Algorithms/quickSort.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | class quickSort
3 | {
4 | static void quicksort(int[] arr,int l,int h)
5 | {
6 | if(l s1 = new Stack();
4 | int flag=0;
5 | for(int i=0;iwidth[i] || length>height[i])
18 | {
19 | System.out.println("UPLOAD ANOTHER");
20 | }
21 | else
22 | {
23 | if(width[i]==height[i])
24 | {
25 | System.out.println("ACCEPTED");
26 | }
27 | else if(width[i]>height[i]||width[i] "0/14"
15 |
16 | s="aaaxbbbbyyhwawiwjjjwwm"
17 | printer_error(s) => "8/22"
18 |
--------------------------------------------------------------------------------
/Reverse Words in a String/Problem Statement.txt:
--------------------------------------------------------------------------------
1 | Given an input string s, reverse the order of the words.
2 |
3 | A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space.
4 |
5 | Return a string of the words in reverse order concatenated by a single space.
6 |
7 | Note that s may contain leading or trailing spaces or multiple spaces between two words. The returned string should only have a single space separating the words. Do not include any extra spaces.
8 |
9 |
10 |
11 | Example 1:
12 |
13 | Input: s = "the sky is blue"
14 | Output: "blue is sky the"
15 | Example 2:
16 |
17 | Input: s = " hello world "
18 | Output: "world hello"
19 | Explanation: Your reversed string should not contain leading or trailing spaces.
20 | Example 3:
21 |
22 | Input: s = "a good example"
23 | Output: "example good a"
24 | Explanation: You need to reduce multiple spaces between two words to a single space in the reversed string.
25 |
26 |
27 | Constraints:
28 |
29 | 1 <= s.length <= 104
30 | s contains English letters (upper-case and lower-case), digits, and spaces ' '.
31 | There is at least one word in s.
32 |
--------------------------------------------------------------------------------
/Zoos/Zoos.java:
--------------------------------------------------------------------------------
1 | //Zoos
2 | import java.util.*;
3 | class Zoos {
4 | public static void main(String args[] ) throws Exception {
5 | Scanner sc =new Scanner(System.in);
6 | String input = sc.next(); // Getting String Input
7 | int zcount=0,ocount=0;
8 | for(int i=0;i1)
23 | {
24 | index--;
25 | }
26 | else
27 | {
28 | index++;
29 | forward=1;
30 | }
31 | }
32 | }
33 | return index;
34 |
35 | }
36 | public static void main(String args[])
37 | {
38 | Scanner sc =new Scanner(System.in);
39 | int n=sc.nextInt();
40 | int t=sc.nextInt();
41 | Solution s =new Solution();
42 | System.out.println(s.passThePillow(n,t));
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Missing Number/code.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int missingNumber(int[] nums) {
3 | if(nums.length==1)
4 | {
5 | if(nums[0]==0)
6 | {
7 | return 1;
8 | }
9 | else
10 | {
11 | return nums[0]-1;
12 | }
13 | }
14 | if(nums[0]==0 && nums[1]==1 && nums.length==2)
15 | {
16 | return 2;
17 | }
18 | if(nums[0]==1 && nums[1]==0 && nums.length==2)
19 | {
20 | return 2;
21 | }
22 | int temp;
23 | for(int i=0;inums[j])
28 | {
29 | temp=nums[i];
30 | nums[i]=nums[j];
31 | nums[j]=temp;
32 | }
33 | }
34 | }
35 | for(int i=0;i=65 &&x<=90)
16 | {
17 | x=x+32;
18 | out=out+(char)x;
19 | }
20 | else
21 | {
22 | out=out+(char)x;
23 | }
24 | }
25 | }
26 | public void reverseString()
27 | {
28 | for(int i=out.length()-1;i>=0;i--)
29 | {
30 | rev=rev+out.charAt(i);
31 | }
32 | }
33 | public boolean generateResult(String x,String y)
34 | {
35 | boolean result=x.equals(y);
36 | return result;
37 | }
38 | public boolean isPalindrome(String s)
39 | {
40 | str=s;
41 | removePunctuations();
42 | toLowerCase();
43 | reverseString();
44 | return generateResult(out,rev);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Java Instanceof keyword/code.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 |
3 |
4 | class Student{}
5 | class Rockstar{ }
6 | class Hacker{}
7 |
8 |
9 | public class InstanceOFTutorial{
10 |
11 | static String count(ArrayList mylist){
12 | int a = 0,b = 0,c = 0;
13 | for(int i = 0; i < mylist.size(); i++){
14 | Object element=mylist.get(i);
15 | if(element instanceof Student)
16 | a++;
17 | if(element instanceof Rockstar)
18 | b++;
19 | if(element instanceof Hacker)
20 | c++;
21 | }
22 | String ret = Integer.toString(a)+" "+ Integer.toString(b)+" "+ Integer.toString(c);
23 | return ret;
24 | }
25 |
26 | public static void main(String []args){
27 | ArrayList mylist = new ArrayList();
28 | Scanner sc = new Scanner(System.in);
29 | int t = sc.nextInt();
30 | for(int i=0; ilt =new Stack();
6 | for(int i=0;i1)
23 | {
24 | index--;
25 | }
26 | else
27 | {
28 | index++;
29 | forward=1;
30 | }
31 | }
32 | }
33 | return index-1;
34 |
35 | }
36 | public static void main(String args[])
37 | {
38 | Scanner sc =new Scanner(System.in);
39 | int tc=sc.nextInt();
40 | for(int i=0;i nums3[b + 1])
33 | {
34 | temp = nums3[b];
35 | nums3[b] = nums3[b + 1];
36 | nums3[b + 1] = temp;
37 | }
38 | }
39 | }
40 |
41 | int index=len-1;
42 | if(len%2==1)
43 | {
44 | median=nums3[(index+1)/2];
45 | }
46 | else
47 | {
48 | median=(double)(nums3[(index/2)]+nums3[(index/2)+1])/2;
49 |
50 | }
51 | return median;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Roman to Integer/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int romanToInt(String s) {
3 | int sum=0,n=0;
4 | for(int i=s.length()-1;i>=0;i--)
5 | {
6 | switch(s.charAt(i))
7 | {
8 | case 'I':
9 | {
10 | n=1;
11 | break;
12 | }
13 | case 'V':
14 | {
15 | n = 5;
16 | break;
17 | }
18 | case 'X':
19 | {
20 | n = 10;
21 | break;
22 | }
23 | case 'L':
24 | {
25 | n = 50;
26 | break;
27 | }
28 | case 'C':
29 | {
30 | n = 100;
31 | break;
32 | }
33 | case 'D':
34 | {
35 | n = 500;
36 | break;
37 | }
38 | case 'M':
39 | {
40 | n = 1000;
41 | break;
42 | }
43 | }
44 | if(4*n=65 && x<=90)
11 | {
12 | x=x+32;
13 | out=out+(char)x;
14 | }
15 | else
16 | {
17 | out=out+s.charAt(i);
18 | }
19 | }
20 | return out;
21 | }
22 | public String Sort(String s)
23 | {
24 | char[] str=s.toCharArray();
25 | char temp;
26 | for(int i=0; i < str.length; i++) {
27 | for(int j=0; j < str.length; j++) {
28 | if(str[j] > str[i]) {
29 | temp = str[i];
30 | str[i] = str[j];
31 | str[j] = temp;
32 | }
33 | }
34 | }
35 | return String.valueOf(str);
36 | }
37 | public static void main(String[] args) {
38 | Scanner sc =new Scanner(System.in);
39 | String a=sc.next();
40 | String b=sc.next();
41 | WithoutInbuild s =new WithoutInbuild();
42 | String s1=s.ToLowerCase(a);
43 | String s2=s.ToLowerCase(b);
44 | String sort1=s.Sort(s1);
45 | String sort2=s.Sort(s2);
46 | String result =(sort1.equals(sort2))?"Anagrams":"Not Anagrams";
47 | System.out.println(result);
48 |
49 | }
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/Proportion Of Numbers/Proportion.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | class Proportion
3 | {
4 | public static int postive(int[] nums)
5 | {
6 | int count=0;
7 | for(int i=0;i0)
10 | {
11 | count++;
12 | }
13 | }
14 | return count;
15 | }
16 | public static int negative(int[] nums)
17 | {
18 | int count=0;
19 | for(int i=0;i 0) {
58 | int data = scan.nextInt();
59 | root = insert(root, data);
60 | }
61 | scan.close();
62 | preOrder(root);
63 | }
64 | }
--------------------------------------------------------------------------------
/geometric_series/question.txt:
--------------------------------------------------------------------------------
1 |
2 | Problem
3 |
4 | Question. Find the nth term of the series.
5 |
6 | 1, 1, 2, 3, 4, 9, 8, 27, 16, 81, 32, 243,64, 729, 128, 2187 ….
7 |
8 | This series is a mixture of 2 series – all the odd terms in this series form a geometric series and all the even terms form yet another geometric series. Write a program to find the Nth term in the series.
9 |
10 | The value N in a positive integer that should be read from STDIN.
11 | The Nth term that is calculated by the program should be written to STDOUT.
12 | Other than value of n th term,no other character / string or message should be written to STDOUT.
13 | For example , if N=16, the 16th term in the series is 2187, so only value 2187 should be printed to STDOUT.
14 |
15 | You can assume that N will not exceed 30.
16 |
17 | Link to this Question
18 |
19 | Test Case 1
20 |
21 | Input- 16
22 | Expected Output – 2187
23 |
24 | Test Case 2
25 |
26 | Input- 13
27 | Expected Output – 64
28 |
29 | (TCS Ninja – Dec 2018 Slot 2)
30 | Explanation
31 |
32 | 1, 1, 2, 3, 4, 9, 8, 27, 16, 81, 32, 243,64, 729, 128, 2187 can represented as :
33 |
34 | 2(0), 3(0),2(1), 3(1),2(2), 3(2),2(3), 3(3),2(4), 3(4),2(5), 3(5),2(6), 3(6) ….
35 |
36 | There are two consecutive sub GP’s at even and odd positions
37 |
38 | (GP-1) At Odd Positions (Powers of 2) – 1, 2, 4, 8, 16, 32, 64, 128
39 | (GP-2) At Even Positions (Powers of 3) – 1, 3, 9, 27, 81, 243, 729, 2187
40 |
41 | Clearly, for calculating Nth position value
42 |
43 | If N is Even, Find (N/2) position in sub GP – 2
44 | If N is Odd, Find (N/2 + 1) position in sub GP – 1
45 |
46 |
--------------------------------------------------------------------------------
/Categorize Box According to Criteria/Question.txt:
--------------------------------------------------------------------------------
1 | Given four integers length, width, height, and mass, representing the dimensions and mass of a box, respectively, return a string representing the category of the box.
2 |
3 | The box is "Bulky" if:
4 | Any of the dimensions of the box is greater or equal to 104.
5 | Or, the volume of the box is greater or equal to 109.
6 | If the mass of the box is greater or equal to 100, it is "Heavy".
7 | If the box is both "Bulky" and "Heavy", then its category is "Both".
8 | If the box is neither "Bulky" nor "Heavy", then its category is "Neither".
9 | If the box is "Bulky" but not "Heavy", then its category is "Bulky".
10 | If the box is "Heavy" but not "Bulky", then its category is "Heavy".
11 | Note that the volume of the box is the product of its length, width and height.
12 |
13 |
14 |
15 | Example 1:
16 |
17 | Input: length = 1000, width = 35, height = 700, mass = 300
18 | Output: "Heavy"
19 | Explanation:
20 | None of the dimensions of the box is greater or equal to 104.
21 | Its volume = 24500000 <= 109. So it cannot be categorized as "Bulky".
22 | However mass >= 100, so the box is "Heavy".
23 | Since the box is not "Bulky" but "Heavy", we return "Heavy".
24 | Example 2:
25 |
26 | Input: length = 200, width = 50, height = 800, mass = 50
27 | Output: "Neither"
28 | Explanation:
29 | None of the dimensions of the box is greater or equal to 104.
30 | Its volume = 8 * 106 <= 109. So it cannot be categorized as "Bulky".
31 | Its mass is also less than 100, so it cannot be categorized as "Heavy" either.
32 | Since its neither of the two above categories, we return "Neither".
33 |
34 |
35 | Constraints:
36 |
37 | 1 <= length, width, height <= 105
38 | 1 <= mass <= 103
39 |
--------------------------------------------------------------------------------
/Sort Colors/Solution.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public void mergeSort(int[] nums,int left,int right)
3 | {
4 | int middle=0;
5 | if(left