Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View itsaboutcode's full-sized avatar
🏠
Working from home

Muhammad Adil itsaboutcode

🏠
Working from home
View GitHub Profile
@itsaboutcode
itsaboutcode / gist:721888
Created November 30, 2010 16:08
Find Min between subarray
int get_min_range(int array[], int firstSubscript, int lastSubscript)
{
int smallestValue = array[firstSubscript];
int smalledIndex = firstSubscript;
for (int i = firstSubscript; i <= lastSubscript; i++)
{
if (array[firstSubscript] < smallestValue)
{
smallestValue = array[firstSubscript];
smalledIndex = firstSubscript;
@itsaboutcode
itsaboutcode / main.cpp
Created February 7, 2011 23:16
Hello World
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
return 0;
}
@itsaboutcode
itsaboutcode / count_values
Created November 18, 2011 10:46
The keys in a dictionary are guaranteed to be unique, but the values are not. Write a function called count_values that takes a single dictionary as an argument and returns the number of distinct values it contains. For example,given the input {’red’:1,
def count_values(dict):
values_count = {}
for key in dict:
values_count[dict[key]] = dict[key]
return len(values_count)
dict = {'red':1, 'green':1, 'blue':2}
print "Unique Values in Dictionary : %d" % count_values(dict)
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@itsaboutcode
itsaboutcode / create_app_without_storyboard.swift
Last active March 24, 2017 06:17
Start iOS application without storyboard
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = UINavigationController(rootViewController: ViewController())
return true
@itsaboutcode
itsaboutcode / minCostToMoveChips.swift
Last active November 17, 2020 14:42
Leetcode: 1217 -  Minimum Cost to Move Chips to The Same Position
class Solution {
func minCostToMoveChips(_ position: [Int]) -> Int {
var even = 0
var odd = 0
for item in position {
if item % 2 == 0 { even = even + 1 }
if item % 2 == 1 { odd = odd + 1 }